mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-08 15:53:19 +00:00
Use fake continuation instead of ALOAD 0 while inlining Do not generate state machine for inner lambdas and inner objects, which capture crossinline suspend lambda. #KT-19159: Fixed
48 lines
973 B
Kotlin
Vendored
48 lines
973 B
Kotlin
Vendored
// FILE: inlined.kt
|
|
// WITH_RUNTIME
|
|
// NO_CHECK_LAMBDA_INLINING
|
|
|
|
suspend inline fun crossinlineMe(crossinline c: suspend () -> Unit) {
|
|
c()
|
|
c()
|
|
}
|
|
|
|
// FILE: inlineSite.kt
|
|
|
|
import kotlin.coroutines.experimental.*
|
|
import kotlin.coroutines.experimental.intrinsics.*
|
|
|
|
fun builder(c: suspend () -> Unit) {
|
|
c.startCoroutine(object: Continuation<Unit> {
|
|
override val context: CoroutineContext
|
|
get() = EmptyCoroutineContext
|
|
|
|
override fun resume(value: Unit) {
|
|
}
|
|
|
|
override fun resumeWithException(exception: Throwable) {
|
|
throw exception
|
|
}
|
|
})
|
|
}
|
|
|
|
var i = 0;
|
|
|
|
suspend fun suspendHere() = suspendCoroutineOrReturn<Unit> {
|
|
i++
|
|
COROUTINE_SUSPENDED
|
|
}
|
|
|
|
fun box(): String {
|
|
builder {
|
|
crossinlineMe {
|
|
suspendHere()
|
|
suspendHere()
|
|
suspendHere()
|
|
suspendHere()
|
|
suspendHere()
|
|
}
|
|
}
|
|
if (i != 1) return "FAIL"
|
|
return "OK"
|
|
} |