Fix transforming of coroutine's create when it is suspend lambda with receiver

Unlike ordinary lambdas suspend lambdas has create method which invokes
the constructor of the lambda object (continuation).
The inliner could not cope with this.
The previous change fixed the case of suspend lambda without receiver.
This change adds support of suspend lambdas with receiver.

 #KT-21605: Fixed
This commit is contained in:
Ilmir Usmanov
2018-03-23 19:57:20 +03:00
parent e96b5f3117
commit 58bac6882d
6 changed files with 59 additions and 2 deletions
+33
View File
@@ -0,0 +1,33 @@
// WITH_RUNTIME
// WITH_COROUTINES
import helpers.*
import kotlin.coroutines.experimental.*
interface Consumer { fun consume(s: String) }
inline fun crossInlineBuilder(crossinline block: (String) -> Unit) = object : Consumer {
override fun consume(s: String) {
block(s)
}
}
fun builder(block: suspend Unit.() -> Unit) {
block.startCoroutine(Unit, EmptyContinuation)
}
class Container {
var y: String = "FAIL"
val consumer = crossInlineBuilder { s ->
builder {
y = s
}
}
}
fun box(): String {
val container = Container()
container.consumer.consume("OK")
return container.y
}