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
40 lines
782 B
Kotlin
Vendored
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
|
|
}
|