effd21d074
`$$forInline` functions do not pass through the state machine generator, and optimizing `Ref`s before that changes how assignments inside lambdas passed to `suspendCoroutine`, etc. behave: without a `Ref`, the assignment is not reflected in the continuation object, so the variable has old value on resumption. These functions will be optimized later, after they are inlined somewhere and the state machine is generated. ^KT-52198 Fixed
41 lines
882 B
Kotlin
Vendored
41 lines
882 B
Kotlin
Vendored
// WITH_COROUTINES
|
|
// WITH_STDLIB
|
|
// TARGET_BACKEND: JVM
|
|
// IGNORE_BACKEND_MULTI_MODULE: JVM, JVM_MULTI_MODULE_IR_AGAINST_OLD
|
|
// FILE: lib.kt
|
|
import kotlin.coroutines.*
|
|
import kotlin.coroutines.intrinsics.*
|
|
|
|
suspend fun foo(value: String): String {
|
|
var x = "fail"
|
|
suspendCoroutineUninterceptedOrReturn<Unit> {
|
|
x = value
|
|
it.resume(Unit)
|
|
COROUTINE_SUSPENDED
|
|
}
|
|
return x
|
|
}
|
|
|
|
suspend inline fun fooInline(value: String): String {
|
|
var x = "fail"
|
|
suspendCoroutineUninterceptedOrReturn<Unit> {
|
|
x = value
|
|
it.resume(Unit)
|
|
COROUTINE_SUSPENDED
|
|
}
|
|
return x
|
|
}
|
|
|
|
// FILE: main.kt
|
|
import helpers.*
|
|
import kotlin.coroutines.*
|
|
import kotlin.coroutines.intrinsics.*
|
|
|
|
fun box(): String {
|
|
var result = ""
|
|
suspend {
|
|
result = foo("O") + fooInline("K")
|
|
}.startCoroutine(EmptyContinuation)
|
|
return result
|
|
}
|