Fix handleResult call generation for statement-like last expression in a block

This commit is contained in:
Denis Zharkov
2016-06-07 13:56:12 +03:00
parent 3a5197d1ae
commit 692acc463a
3 changed files with 41 additions and 4 deletions
@@ -0,0 +1,29 @@
var globalResult = ""
class Controller {
suspend fun suspendWithValue(v: String, x: Continuation<String>) {
x.resume(v)
}
operator fun handleResult(x: String, c: Continuation<Nothing>) {
globalResult = x
}
}
fun builder(coroutine c: Controller.() -> Continuation<Unit>) {
c(Controller()).resume(Unit)
}
fun box(): String {
var condition = true
builder {
if (condition) {
suspendWithValue("OK")
} else {
suspendWithValue("fail 1")
}
}
return globalResult
}