KT-15017 Throwing exception in the end of inline suspend-functions lead to internal compiler error

Suspend function call with a reachable (alive) begin marker and unreachable (dead) end marker
is an exit point for the corresponding coroutine.
It isn't a suspension point, and doesn't introduce a new state in the coroutine FSM.
This commit is contained in:
Dmitry Petrov
2017-01-24 16:46:52 +03:00
parent 3be1174824
commit e05f2eaff6
9 changed files with 137 additions and 22 deletions
+25
View File
@@ -0,0 +1,25 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.startCoroutine
class Controller {
suspend inline fun suspendInlineThrow(v: String): String = throw RuntimeException(v)
suspend inline fun suspendInline(v: String) = v
}
fun builder(c: suspend Controller.() -> Unit) {
c.startCoroutine(Controller(), EmptyContinuation)
}
class OK
fun box(): String {
var result = ""
builder {
result = try { suspendInlineThrow("OK") } catch (e: RuntimeException) { e.message!! }
// result = suspendInline("OK")
}
return result
}