Use proper coroutine class descriptor for extension receiver generation

Before this commit context.getThisDescriptor() has been used, that was quite correct
until suspension happens inside inlined lambda (it has different this-descriptor)
This commit is contained in:
Denis Zharkov
2016-05-25 14:52:16 +03:00
parent 75e112e752
commit 94bd6dcc82
3 changed files with 43 additions and 4 deletions
@@ -0,0 +1,31 @@
class Controller {
suspend fun suspendHere(v: Int, x: Continuation<Int>) {
x.resume(v * 2)
}
}
fun builder(coroutine c: Controller.() -> Continuation<Unit>) {
c(Controller()).resume(Unit)
}
inline fun foo(x: (Int) -> Unit) {
for (i in 1..2) {
x(i)
}
}
fun box(): String {
var result = ""
builder {
result += "-"
foo {
result += suspendHere(it).toString()
}
result += "+"
}
if (result != "-24+") return "fail: $result"
return "OK"
}