as a return type and ran into a weird issue. Does anybody know if this is already known? I couldn't find anything in the issue tracker.
Copy code
suspend fun foo() = suspendCancellableCoroutine<Unit> {
thread {
it.resumeWithException(RuntimeException("foo"))
}
}
suspend fun fooWithResult(): Result<Unit> = runCatching { foo() }
@Test
fun resultTest() = runBlocking {
// when fooWithResult is not inlined the exception is not caught by "runCatching"
val result = fooWithResult()
Assertions.assertTrue { result.isFailure }
delay(5000)
Unit
}
The test passes if I mark
fooWithResult
as inline. Without it the exception is not caught by
runCatching
a
araqnid
08/24/2020, 2:48 PM
Coroutines returning kotlin.Result is an issue, at least in 1.3.x, because it’s used internally. I came across this, and there was some combination of either compiler or intellij that flagged it as a warning