Fix problem with missing handleResult call

At first we try to resolve 'handleResult' just as last expression
in a lambda is first argument, then if results are unsuccessful
try resolve 'handleResult' with fake Unit expression

 #KT-12969 Fixed
This commit is contained in:
Denis Zharkov
2016-07-04 18:07:16 +03:00
parent 888db4b3b5
commit a420fda825
3 changed files with 57 additions and 10 deletions
@@ -0,0 +1,28 @@
class Controller {
var isCompleted = false
suspend fun suspendHere(x: Continuation<String>) {
x.resume("OK")
}
operator fun handleResult(x: Unit, y: Continuation<Nothing>) {
isCompleted = true
}
}
fun builder(coroutine c: Controller.() -> Continuation<Unit>) {
val controller = Controller()
c(controller).resume(Unit)
if (!controller.isCompleted) throw java.lang.RuntimeException("fail")
}
fun box(): String {
builder {
"OK"
}
builder {
suspendHere()
}
return "OK"
}