Files
kotlin-fork/compiler/testData/codegen/boxInline/suspend/stateMachine/kt30708.kt
T
Alexander Udalov 5480faf5c5 Add tests for issues fixed in JVM IR and other obsolete issues
#KT-6007
 #KT-16445
 #KT-17753
 #KT-22488
 #KT-23881
 #KT-24135
 #KT-26360
 #KT-27427
 #KT-27449
 #KT-27830
 #KT-28042
 #KT-29595
 #KT-30708
 #KT-32793
2021-02-01 18:29:59 +01:00

48 lines
906 B
Kotlin
Vendored

// WITH_RUNTIME
// WITH_COROUTINES
// CHECK_STATE_MACHINE
// FILE: inline.kt
import helpers.*
interface SuspendRunnable {
suspend fun run(): String
}
inline fun inlineMe(crossinline c1: suspend (String) -> String) =
object : SuspendRunnable {
override suspend fun run(): String {
return c1(
return try { "OK" } catch (e: Exception) { e.message!! }
)
}
}
inline fun inlineMe2(crossinline c2: suspend (String) -> String) =
inlineMe(c2)
// FILE: box.kt
import helpers.*
import kotlin.coroutines.*
fun builder(c: suspend () -> Unit) {
c.startCoroutine(CheckStateMachineContinuation)
}
fun box(): String {
val r = inlineMe2 {
StateMachineChecker.suspendHere()
it
}
var res = "FAIL"
builder {
res = r.run()
}
StateMachineChecker.check(numberOfSuspensions = 0)
return res
}