Generate last expression in coroutine block even for Unit expected type
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
class Controller {
|
||||
var ok = false
|
||||
var v = "fail"
|
||||
suspend fun suspendHere(v: String, x: Continuation<Unit>) {
|
||||
this.v = v
|
||||
x.resume(Unit)
|
||||
}
|
||||
|
||||
operator fun handleResult(u: Unit, v: Continuation<Nothing>) {
|
||||
ok = true
|
||||
}
|
||||
}
|
||||
|
||||
fun builder(coroutine c: Controller.() -> Continuation<Unit>): String {
|
||||
val controller = Controller()
|
||||
c(controller).resume(Unit)
|
||||
if (!controller.ok) throw java.lang.RuntimeException("Fail 1")
|
||||
return controller.v
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
|
||||
return builder {
|
||||
suspendHere("OK")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user