Validate label value of coroutine in case of no suspension points

#KT-14718 Fixed
This commit is contained in:
Denis Zharkov
2016-11-09 12:00:33 +03:00
parent 46b91365ba
commit ae70a60a0a
5 changed files with 59 additions and 3 deletions
+21 -1
View File
@@ -35,7 +35,27 @@ fun box(): String {
return "fail 3"
} catch (e: java.lang.IllegalStateException) {
if (e.message != "call to 'resume' before 'invoke' with coroutine") return "fail 4: ${e.message!!}"
return "OK"
}
var result = "OK"
try {
builder1 {
result = "fail 5"
}
return "fail 6"
} catch (e: java.lang.IllegalStateException) {
if (e.message != "call to 'resume' before 'invoke' with coroutine") return "fail 7: ${e.message!!}"
}
try {
builder2 {
result = "fail 8"
}
return "fail 9"
} catch (e: java.lang.IllegalStateException) {
if (e.message != "call to 'resume' before 'invoke' with coroutine") return "fail 10: ${e.message!!}"
return result
}
return "fail"
@@ -0,0 +1,26 @@
class Controller {
var res = 0
operator fun handleResult(x: Int, y: Continuation<Nothing>) {
res = x
}
}
fun builder(coroutine c: Controller.() -> Continuation<Unit>): Int {
val controller = Controller()
c(controller).resume(Unit)
return controller.res
}
fun box(): String {
var result = ""
val handledResult = builder {
result = "OK"
56
}
if (handledResult != 56) return "fail 1: $handledResult"
return result
}