Check for COROUTINE_SUSPENDED inside callable reference

#KT-41429 Fixed
This commit is contained in:
Ilmir Usmanov
2020-09-01 21:34:31 +02:00
parent 4303e8126f
commit 1c97eafea8
17 changed files with 98 additions and 14 deletions
@@ -0,0 +1,30 @@
// IGNORE_BACKEND: JS_IR
// IGNORE_BACKEND: JS_IR_ES6
// WITH_RUNTIME
// WITH_COROUTINES
import helpers.*
import kotlin.coroutines.*
inline class R(val x: Any)
fun builder(c: suspend () -> Unit) {
c.startCoroutine(EmptyContinuation)
}
suspend fun <T> call(fn: suspend () -> T) = fn()
fun useR(r: R) = if (r.x == "OK") "OK" else "fail: $r"
var c: Continuation<R>? = null
suspend fun ok() = suspendCoroutine<R> { c = it }
fun box(): String {
var res: String = "fail"
builder {
res = useR(call(::ok))
}
c?.resume(R("OK"))
return res
}
@@ -1,5 +1,6 @@
// WITH_RUNTIME
// WITH_COROUTINES
// IGNORE_BACKEND: JVM_IR
import helpers.*
import kotlin.coroutines.*