Files
kotlin/compiler/testData/codegen/box/coroutines/inlineFunInGenericClass.kt
Denis Zharkov aef5911c7e Obtain original suspend function view for inline codegen
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
2017-08-30 16:19:43 +03:00

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
}