mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-08 08:31:26 +00:00
It's necessary for generic inline suspend as a codegen for it uses binding slice SUSPEND_FUNCTION_TO_JVM_VIEW to generate fake continuation parameter, so all the descriptors that are used for body generation must be obtained from the SUSPEND_FUNCTION_TO_JVM_VIEW #KT-19528 Fixed
32 lines
596 B
Kotlin
Vendored
32 lines
596 B
Kotlin
Vendored
// WITH_RUNTIME
|
|
// WITH_COROUTINES
|
|
import helpers.*
|
|
import kotlin.coroutines.experimental.*
|
|
import kotlin.coroutines.experimental.intrinsics.*
|
|
|
|
suspend fun suspendThere(v: Any?): String = suspendCoroutineOrReturn { x ->
|
|
x.resume(v?.toString() ?: "<empty>")
|
|
COROUTINE_SUSPENDED
|
|
}
|
|
|
|
|
|
class A<T>(val arg: T) {
|
|
var result = ""
|
|
inline suspend fun foo() {
|
|
result = suspendThere(arg)
|
|
}
|
|
}
|
|
|
|
fun builder(c: suspend () -> Unit) {
|
|
c.startCoroutine(EmptyContinuation)
|
|
}
|
|
|
|
fun box(): String {
|
|
val a = A<String>("OK")
|
|
builder {
|
|
a.foo()
|
|
}
|
|
|
|
return a.result
|
|
}
|