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
2121import kotlinx.serialization.SerialFormat
2222import kotlinx.serialization.StringFormat
2323import kotlin.coroutines.CoroutineContext
24+ import kotlin.reflect.typeOf
2425
2526internal class KrpcServerService <@Rpc T : Any >(
2627 private val service : T ,
@@ -178,6 +179,13 @@ internal class KrpcServerService<@Rpc T : Any>(
178179 is RpcInvokator .Field -> {
179180 invokator.call(service)
180181 }
182+ }.let { interceptedValue ->
183+ // KRPC-173
184+ if (callable.returnType.kType == typeOf<Unit >()) {
185+ Unit
186+ } else {
187+ interceptedValue
188+ }
181189 }
182190
183191 val returnType = callable.returnType
Original file line number Diff line number Diff line change @@ -111,6 +111,8 @@ interface KrpcTestService : RemoteService {
111111
112112 suspend fun answerToAnything (arg : String ): Int
113113
114+ suspend fun krpc173 ()
115+
114116 val plainFlowOfInts : Flow <Int >
115117
116118 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) :
273273 return 42
274274 }
275275
276+ private suspend fun doWork (): String {
277+ delay(1 )
278+ return " qwerty"
279+ }
280+
281+ override suspend fun krpc173 () {
282+ doWork()
283+ }
284+
276285 override val plainFlowOfInts: Flow <Int > = plainFlow { it }
277286
278287 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 {
564564 awaitAll(c1, c2)
565565 }
566566
567+ @Test
568+ fun testKrpc173 () = runTest {
569+ assertEquals(Unit , client.krpc173())
570+ }
571+
567572 @Test
568573 fun testPlainFlowOfInts () = runTest {
569574 val flow = client.plainFlowOfInts.toList()
You can’t perform that action at this time.
0 commit comments