Files
kotlin-fork/compiler/testData/codegen/boxInline/suspend/crossinlineSuspendLambdaInsideCrossinlineSuspendLambda.kt
T
Ilmir Usmanov 6854135077 Support crossinline suspend lambda as parameter of inline function
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
2018-03-16 16:26:11 +03:00

38 lines
798 B
Kotlin
Vendored

// FILE: test.kt
// WITH_RUNTIME
import kotlin.coroutines.experimental.*
inline suspend fun foo(crossinline a: suspend () -> Unit, crossinline b: suspend () -> Unit) {
var x = "OK"
bar { x; a(); b() }
}
inline suspend fun bar(crossinline l: suspend () -> Unit) {
val c : suspend () -> Unit = { l() }
c()
}
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
}
})
}
// FILE: box.kt
fun box(): String {
var y = "fail"
builder {
foo({ y = "O" }) { y += "K" }
}
return y
}