Files
kotlin-fork/compiler/testData/codegen/boxInline/suspend/stateMachine/innerObject.kt
T
Denis Zharkov 0b3048f60a Replace trivial usages of suspendCoroutineOrReturn in tests
This is necessary since suspendCoroutineOrReturn gets removed in 1.3
2018-07-09 15:27:19 +03:00

51 lines
947 B
Kotlin
Vendored

// FILE: inlined.kt
// COMMON_COROUTINES_TEST
// WITH_RUNTIME
// WITH_COROUTINES
// NO_CHECK_LAMBDA_INLINING
interface SuspendRunnable {
suspend fun run()
}
suspend inline fun crossinlineMe(crossinline c: suspend () -> Unit) {
val o = object : SuspendRunnable {
override suspend fun run() {
c()
}
}
o.run()
}
// FILE: inlineSite.kt
// COMMON_COROUTINES_TEST
import COROUTINES_PACKAGE.*
import COROUTINES_PACKAGE.intrinsics.*
import helpers.*
fun builder(c: suspend () -> Unit) {
c.startCoroutine(EmptyContinuation)
}
var i = 0;
suspend fun suspendHere() = suspendCoroutineUninterceptedOrReturn<Unit> {
i++
COROUTINE_SUSPENDED
}
fun box(): String {
builder {
crossinlineMe {
suspendHere()
suspendHere()
suspendHere()
suspendHere()
suspendHere()
}
}
if (i != 1) return "FAIL $i"
return "OK"
}