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:
+34
@@ -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"
|
||||
}
|
||||
Reference in New Issue
Block a user