Make suspension calls generation more stable

Instead of performing signature change during transformation
it's convinient to make just when generating corresponding call,
for example there is no need to think about default parameters as they just work as is

See comment above replaceSuspensionFunctionViewWithRealDescriptor for clarification
This commit is contained in:
Denis Zharkov
2016-05-26 14:10:26 +03:00
parent 84ae28992e
commit b1189eff23
6 changed files with 149 additions and 23 deletions
@@ -0,0 +1,41 @@
class Controller {
suspend fun suspendHere(a: String = "abc", i: Int = 2, x: Continuation<String>) {
x.resume(a + "#" + (i + 1))
}
}
fun builder(coroutine c: Controller.() -> Continuation<Unit>) {
c(Controller()).resume(Unit)
}
fun box(): String {
var result = "OK"
builder {
var a = suspendHere()
if (a != "abc#3") {
result = "fail 1: $a"
throw RuntimeException(result)
}
a = suspendHere("cde")
if (a != "cde#3") {
result = "fail 2: $a"
throw RuntimeException(result)
}
a = suspendHere(i = 6)
if (a != "abc#7") {
result = "fail 3: $a"
throw RuntimeException(result)
}
a = suspendHere("xyz", 9)
if (a != "xyz#10") {
result = "fail 4: $a"
throw RuntimeException(result)
}
}
return result
}