JVM_IR: do not handle Nothing in suspend tail call bridges

Else they wouldn't be tail call, would they?
This commit is contained in:
pyos
2020-05-07 14:48:07 +02:00
committed by Ilmir Usmanov
parent 0acaedef92
commit 8809abdbac
10 changed files with 74 additions and 10 deletions
@@ -0,0 +1,34 @@
// IGNORE_BACKEND_FIR: JVM_IR
// WITH_RUNTIME
// WITH_COROUTINES
import helpers.*
import kotlin.coroutines.*
import kotlin.coroutines.intrinsics.*
suspend fun suspendThenThrow(): Nothing {
suspendCoroutineUninterceptedOrReturn<Unit> {
it.resume(Unit)
COROUTINE_SUSPENDED
}
throw RuntimeException()
}
suspend fun foo(x: Int = 1): Nothing = suspendThenThrow()
interface I {
suspend fun bar(): Nothing
}
class C : I by (object : I {
override suspend fun bar(): Nothing = suspendThenThrow()
})
var result = ""
fun box(): String {
suspend {
try { foo() } catch (e: RuntimeException) { result += "O" }
try { C().bar() } catch (e: RuntimeException) { result += "K" }
}.startCoroutine(EmptyContinuation)
return result
}