JVM_IR: do not box inline classes in suspend multifile bridges

This commit is contained in:
pyos
2021-04-22 12:39:49 +02:00
committed by Ilmir Usmanov
parent 7d95943b8b
commit 23ffbe4d9e
9 changed files with 97 additions and 58 deletions
@@ -0,0 +1,29 @@
// TARGET_PLATFORM: JVM
// WITH_RUNTIME
// WITH_COROUTINES
// FILE: a.kt
@file:JvmMultifileClass
@file:JvmName("A")
import kotlin.coroutines.*
import kotlin.coroutines.intrinsics.*
@Suppress("UNSUPPORTED_FEATURE")
inline class I(val x: Any?)
suspend fun <T> suspendHere(x: T): T = suspendCoroutineUninterceptedOrReturn {
it.resume(x)
COROUTINE_SUSPENDED
}
suspend fun f(): I = I(suspendHere("OK"))
// FILE: z.kt
import helpers.*
import kotlin.coroutines.*
fun box(): String {
var result = "fail"
suspend { result = f().x as String }.startCoroutine(EmptyContinuation)
return result
}
@@ -8,16 +8,13 @@ import kotlin.coroutines.intrinsics.*
@Suppress("UNSUPPORTED_FEATURE")
inline class I(val x: Any?)
suspend fun suspendHere(): Unit = suspendCoroutineUninterceptedOrReturn { c ->
c.resume(Unit)
suspend fun <T> suspendHere(x: T): T = suspendCoroutineUninterceptedOrReturn {
it.resume(x)
COROUTINE_SUSPENDED
}
class C {
private suspend fun f(): I {
suspendHere()
return I("OK")
}
private suspend fun f(): I = I(suspendHere("OK"))
fun g() = suspend { f() }
}