JVM_IR: apply TailCallOptimizationLowering to all suspend functions

Even if a function is known to be tail call because it's a compiler
generated bridge, the tail return might still need to be added in case
of Unit return type.
This commit is contained in:
pyos
2020-03-09 14:33:59 +01:00
committed by Ilmir Usmanov
parent dc388f3f3a
commit 735fae0e5a
8 changed files with 82 additions and 21 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 pause(): Unit = suspendCoroutineUninterceptedOrReturn { x ->
x.resume(Unit)
COROUTINE_SUSPENDED
}
interface I {
suspend fun f()
}
var unpaused = false
class A : I {
override suspend fun f() {
pause()
unpaused = true
}
}
class B(val x: I) : I by x
fun box(): String {
suspend {
B(A()).f()
}.startCoroutine(EmptyContinuation)
return if (unpaused) "OK" else "fail: ignored suspension"
}