mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-17 08:31:29 +00:00
34 lines
698 B
Kotlin
Vendored
34 lines
698 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 {
|
|
suspend fun suspendHere(): String = suspendCoroutineUninterceptedOrReturn { x ->
|
|
x.resumeWithException(RuntimeException("OK"))
|
|
COROUTINE_SUSPENDED
|
|
}
|
|
}
|
|
|
|
fun builder(c: suspend Controller.() -> Unit) {
|
|
c.startCoroutine(Controller(), EmptyContinuation)
|
|
}
|
|
|
|
fun box(): String {
|
|
var result = ""
|
|
|
|
builder {
|
|
try {
|
|
suspendHere()
|
|
result = "fail"
|
|
} catch (e: RuntimeException) {
|
|
result = "OK"
|
|
}
|
|
}
|
|
|
|
return result
|
|
}
|