fc70455877
Now AddContinuationLowering is responsible for both adding continuation classes to suspend functions and adding continuation parameters to them. Because we cannot create a view if inline suspend function is defined in another file, we generate a stub without body when we encounter call to it. And then, when we lower the file containing the function we add the body. This way we have no unlowered views after the lowering. Thus, after the lowering there should be no suspend function, which are not views, therefore, remove VIEW origins. Because transformations of suspend functions can copy them into another object, use attribute as a key inside function to view map.
48 lines
906 B
Kotlin
Vendored
48 lines
906 B
Kotlin
Vendored
// FILE: test.kt
|
|
// COMMON_COROUTINES_TEST
|
|
// WITH_RUNTIME
|
|
// WITH_COROUTINES
|
|
// NO_CHECK_LAMBDA_INLINING
|
|
|
|
import COROUTINES_PACKAGE.*
|
|
import helpers.*
|
|
|
|
class Controller {
|
|
var res = "FAIL 1"
|
|
}
|
|
|
|
val defaultController = Controller()
|
|
|
|
suspend inline fun test(controller: Controller = defaultController, c: suspend Controller.() -> Unit) {
|
|
controller.c()
|
|
}
|
|
|
|
// FILE: box.kt
|
|
// COMMON_COROUTINES_TEST
|
|
|
|
import COROUTINES_PACKAGE.*
|
|
import helpers.*
|
|
|
|
fun builder(c: suspend () -> Unit) {
|
|
c.startCoroutine(EmptyContinuation)
|
|
}
|
|
|
|
suspend fun calculate() = "OK"
|
|
|
|
fun box() : String {
|
|
builder {
|
|
test {
|
|
res = calculate()
|
|
}
|
|
}
|
|
if (defaultController.res != "OK") return defaultController.res
|
|
val controller = Controller()
|
|
controller.res = "FAIL 2"
|
|
builder {
|
|
test(controller) {
|
|
res = calculate()
|
|
}
|
|
}
|
|
return controller.res
|
|
}
|