Reflection: do not try to box COROUTINE_SUSPENDED

#KT-58887 Fixed
This commit is contained in:
Alexander Udalov
2023-08-15 18:54:59 +02:00
committed by Space Team
parent bd6af5cc42
commit a58a1a3398
8 changed files with 71 additions and 0 deletions
@@ -0,0 +1,34 @@
// TARGET_BACKEND: JVM
// WITH_REFLECT
// WITH_COROUTINES
import helpers.EmptyContinuation
import kotlin.coroutines.Continuation
import kotlin.coroutines.startCoroutine
import kotlin.coroutines.suspendCoroutine
import kotlin.reflect.KFunction
import kotlin.reflect.full.callSuspendBy
var c: Continuation<Z>? = null
suspend fun suspendMe(): Z =
suspendCoroutine { c = it }
fun builder(c: suspend () -> Unit) {
c.startCoroutine(EmptyContinuation())
}
fun box(): String {
var result = Z("Fail")
builder {
val ref: KFunction<Z> = ::suspendMe
result = ref.callSuspendBy(emptyMap())
}
c!!.resumeWith(Result.success(Z("OK")))
return result.value
}
@JvmInline
value class Z(val value: String) {
override fun toString(): String = value
}