mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-16 15:53:55 +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
43 lines
941 B
Kotlin
Vendored
43 lines
941 B
Kotlin
Vendored
// IGNORE_BACKEND: JVM_IR
|
|
// WITH_RUNTIME
|
|
// WITH_COROUTINES
|
|
// COMMON_COROUTINES_TEST
|
|
import helpers.*
|
|
import COROUTINES_PACKAGE.*
|
|
import COROUTINES_PACKAGE.intrinsics.*
|
|
|
|
suspend fun suspendHere(): Any = suspendCoroutineUninterceptedOrReturn { x -> }
|
|
|
|
fun builder(c: suspend () -> Unit) {
|
|
var exception: Throwable? = null
|
|
|
|
c.createCoroutine(object : ContinuationAdapter<Unit>() {
|
|
override val context = EmptyCoroutineContext
|
|
|
|
override fun resume(data: Unit) {
|
|
}
|
|
|
|
override fun resumeWithException(e: Throwable) {
|
|
exception = e
|
|
}
|
|
}).resumeWithException(RuntimeException("OK"))
|
|
|
|
if (exception?.message != "OK") {
|
|
throw RuntimeException("Unexpected result: ${exception?.message}")
|
|
}
|
|
}
|
|
|
|
fun box(): String {
|
|
var result = "OK"
|
|
builder {
|
|
suspendHere()
|
|
result = "fail 1"
|
|
}
|
|
|
|
builder {
|
|
result = "fail 2"
|
|
}
|
|
|
|
return result
|
|
}
|