mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-17 00:21:28 +00:00
34 lines
747 B
Kotlin
Vendored
34 lines
747 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 ok = false
|
|
var v = "fail"
|
|
suspend fun suspendHere(v: String): Unit = suspendCoroutineUninterceptedOrReturn { x ->
|
|
this.v = v
|
|
x.resume(Unit)
|
|
COROUTINE_SUSPENDED
|
|
}
|
|
}
|
|
|
|
fun builder(c: suspend Controller.() -> Unit): String {
|
|
val controller = Controller()
|
|
c.startCoroutine(controller, handleResultContinuation {
|
|
controller.ok = true
|
|
})
|
|
if (!controller.ok) throw RuntimeException("Fail 1")
|
|
return controller.v
|
|
}
|
|
|
|
fun box(): String {
|
|
|
|
return builder {
|
|
suspendHere("OK")
|
|
}
|
|
}
|