mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-17 08:31:29 +00:00
* Move FinallyBlockLowering to common part * Fix catching of dynamic exception * Fix bridges for suspend functions * Disable explicit cast to Unit * Run lowering per module * Update some test data
47 lines
946 B
Kotlin
Vendored
47 lines
946 B
Kotlin
Vendored
// IGNORE_BACKEND: JVM_IR
|
|
// WITH_RUNTIME
|
|
// WITH_COROUTINES
|
|
// COMMON_COROUTINES_TEST
|
|
import helpers.*
|
|
import COROUTINES_PACKAGE.*
|
|
import COROUTINES_PACKAGE.intrinsics.*
|
|
|
|
class Controller {
|
|
var result = false
|
|
suspend fun suspendHere(): String = suspendCoroutineUninterceptedOrReturn { x ->
|
|
x.resume("OK")
|
|
COROUTINE_SUSPENDED
|
|
}
|
|
|
|
fun foo() {
|
|
result = true
|
|
}
|
|
}
|
|
|
|
fun builder(c: suspend Controller.() -> Unit) {
|
|
val controller = Controller()
|
|
c.startCoroutine(controller, EmptyContinuation)
|
|
if (!controller.result) throw RuntimeException("fail")
|
|
}
|
|
|
|
fun noinlineRun(block: () -> Unit) {
|
|
block()
|
|
}
|
|
|
|
fun box(): String {
|
|
builder {
|
|
if (suspendHere() != "OK") {
|
|
throw RuntimeException("fail 1")
|
|
}
|
|
noinlineRun {
|
|
foo()
|
|
}
|
|
|
|
if (suspendHere() != "OK") {
|
|
throw RuntimeException("fail 2")
|
|
}
|
|
}
|
|
|
|
return "OK"
|
|
}
|