Reflection: do not try to box COROUTINE_SUSPENDED
#KT-58887 Fixed
This commit is contained in:
committed by
Space Team
parent
bd6af5cc42
commit
a58a1a3398
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user