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:
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user