MiSikora
09/07/2020, 7:37 PMkotlin.Result.Failure
throws instead of delivering value when continuation is resumed on a different thread?
suspend fun main() {
val failure = fail()
println(failure)
}
suspend fun fail() = suspendCoroutine<Result<String>> {
Executors.newSingleThreadExecutor().execute {
it.resume(Result.failure(RuntimeException()))
}
}
Exception in thread "main" java.lang.RuntimeException
at MainKt$fail$2$1.run(main.kt:12)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
fail()
function inline
seems to resolve the issue. Anyone knows why that might be?gildor
09/07/2020, 11:43 PMMiSikora
09/08/2020, 12:03 PM1.3.72
works properly, but 1.4.20-dev-3296-10
still failsgildor
09/08/2020, 2:16 PMMiSikora
09/08/2020, 2:20 PM