Files
kotlin-fork/compiler/testData/codegen/box/reflection/call/inlineClasses/kt58887.kt
T
Alexander Udalov a58a1a3398 Reflection: do not try to box COROUTINE_SUSPENDED
#KT-58887 Fixed
2023-08-18 10:35:34 +00:00

35 lines
783 B
Kotlin
Vendored

// 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
}