File tree Expand file tree Collapse file tree 4 files changed +24
-0
lines changed
krpc-server/src/commonMain/kotlin/kotlinx/rpc/krpc/server/internal
krpc-test/src/commonMain/kotlin/kotlinx/rpc/krpc/test Expand file tree Collapse file tree 4 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ import kotlinx.serialization.KSerializer
21
21
import kotlinx.serialization.SerialFormat
22
22
import kotlinx.serialization.StringFormat
23
23
import kotlin.coroutines.CoroutineContext
24
+ import kotlin.reflect.typeOf
24
25
25
26
internal class KrpcServerService <@Rpc T : Any >(
26
27
private val service : T ,
@@ -178,6 +179,13 @@ internal class KrpcServerService<@Rpc T : Any>(
178
179
is RpcInvokator .Field -> {
179
180
invokator.call(service)
180
181
}
182
+ }.let { interceptedValue ->
183
+ // KRPC-173
184
+ if (callable.returnType.kType == typeOf<Unit >()) {
185
+ Unit
186
+ } else {
187
+ interceptedValue
188
+ }
181
189
}
182
190
183
191
val returnType = callable.returnType
Original file line number Diff line number Diff line change @@ -111,6 +111,8 @@ interface KrpcTestService : RemoteService {
111
111
112
112
suspend fun answerToAnything (arg : String ): Int
113
113
114
+ suspend fun krpc173 ()
115
+
114
116
val plainFlowOfInts : Flow <Int >
115
117
116
118
val plainFlowOfFlowsOfInts : Flow <Flow <Int >>
Original file line number Diff line number Diff line change @@ -273,6 +273,15 @@ class KrpcTestServiceBackend(override val coroutineContext: CoroutineContext) :
273
273
return 42
274
274
}
275
275
276
+ private suspend fun doWork (): String {
277
+ delay(1 )
278
+ return " qwerty"
279
+ }
280
+
281
+ override suspend fun krpc173 () {
282
+ doWork()
283
+ }
284
+
276
285
override val plainFlowOfInts: Flow <Int > = plainFlow { it }
277
286
278
287
override val plainFlowOfFlowsOfInts: Flow <Flow <Int >> = plainFlow { plainFlow { i -> i } }
Original file line number Diff line number Diff line change @@ -564,6 +564,11 @@ abstract class KrpcTransportTestBase {
564
564
awaitAll(c1, c2)
565
565
}
566
566
567
+ @Test
568
+ fun testKrpc173 () = runTest {
569
+ assertEquals(Unit , client.krpc173())
570
+ }
571
+
567
572
@Test
568
573
fun testPlainFlowOfInts () = runTest {
569
574
val flow = client.plainFlowOfInts.toList()
You can’t perform that action at this time.
0 commit comments