Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import kotlinx.serialization.KSerializer
import kotlinx.serialization.SerialFormat
import kotlinx.serialization.StringFormat
import kotlin.coroutines.CoroutineContext
import kotlin.reflect.typeOf

internal class KrpcServerService<@Rpc T : Any>(
private val service: T,
Expand Down Expand Up @@ -178,6 +179,13 @@ internal class KrpcServerService<@Rpc T : Any>(
is RpcInvokator.Field -> {
invokator.call(service)
}
}.let { interceptedValue ->
// KRPC-173
if (callable.returnType.kType == typeOf<Unit>()) {
Unit
} else {
interceptedValue
}
}

val returnType = callable.returnType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ interface KrpcTestService : RemoteService {

suspend fun answerToAnything(arg: String): Int

suspend fun krpc173()

val plainFlowOfInts : Flow<Int>

val plainFlowOfFlowsOfInts : Flow<Flow<Int>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,15 @@ class KrpcTestServiceBackend(override val coroutineContext: CoroutineContext) :
return 42
}

private suspend fun doWork(): String {
delay(1)
return "qwerty"
}

override suspend fun krpc173() {
doWork()
}

override val plainFlowOfInts: Flow<Int> = plainFlow { it }

override val plainFlowOfFlowsOfInts: Flow<Flow<Int>> = plainFlow { plainFlow { i -> i } }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,11 @@ abstract class KrpcTransportTestBase {
awaitAll(c1, c2)
}

@Test
fun testKrpc173() = runTest {
assertEquals(Unit, client.krpc173())
}

@Test
fun testPlainFlowOfInts() = runTest {
val flow = client.plainFlowOfInts.toList()
Expand Down