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:
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user