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