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 @@ -108,6 +108,8 @@ interface KrpcTestService : RemoteService {
108108
109109 suspend fun answerToAnything (arg : String ): Int
110110
111+ suspend fun krpc173 ()
112+
111113 val plainFlowOfInts : Flow <Int >
112114
113115 val plainFlowOfFlowsOfInts : Flow <Flow <Int >>
Original file line number Diff line number Diff line change @@ -265,6 +265,15 @@ class KrpcTestServiceBackend(override val coroutineContext: CoroutineContext) :
265265 return 42
266266 }
267267
268+ private suspend fun doWork (): String {
269+ delay(1 )
270+ return " qwerty"
271+ }
272+
273+ override suspend fun krpc173 () {
274+ doWork()
275+ }
276+
268277 override val plainFlowOfInts: Flow <Int > = plainFlow { it }
269278
270279 override val plainFlowOfFlowsOfInts: Flow <Flow <Int >> = plainFlow { plainFlow { i -> i } }
Original file line number Diff line number Diff line change @@ -548,6 +548,11 @@ abstract class KrpcTransportTestBase {
548548 awaitAll(c1, c2)
549549 }
550550
551+ @Test
552+ fun testKrpc173 () = runTest {
553+ assertEquals(Unit , client.krpc173())
554+ }
555+
551556 @Test
552557 fun testPlainFlowOfInts () = runTest {
553558 val flow = client.plainFlowOfInts.toList()
You can’t perform that action at this time.
0 commit comments