Files
kotlin/compiler/testData/codegen/box/coroutines/inlineGenericFunCalledFromSubclass.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

40 lines
782 B
Kotlin
Vendored

// WITH_RUNTIME
// WITH_COROUTINES
// WITH_REFLECT
import helpers.*
import kotlin.coroutines.experimental.*
import kotlin.coroutines.experimental.intrinsics.*
suspend fun suspendThere(v: String): String = suspendCoroutineOrReturn { x ->
x.resume(v)
COROUTINE_SUSPENDED
}
suspend fun foo(x: suspend () -> String): String = x()
abstract class A {
inline suspend fun <reified T : Any> baz(): String {
return foo {
suspendThere(T::class.simpleName!!)
}
}
}
class B : A() {
suspend fun bar(): String {
return baz<OK>()
}
}
fun builder(c: suspend () -> Unit) {
c.startCoroutine(EmptyContinuation)
}
class OK
fun box(): String {
var result = "fail"
builder {
result = B().bar()
}
return result
}