IR: generate lambdas in place in Psi2Ir

even when arguments are to be rearranged.
Lambdas have no side effects, and storing them in temporary variables
prevents processing in the backend
(such as inserting continuation parameter in AddContinuationLowering).
This commit is contained in:
Georgy Bronnikov
2020-03-19 11:45:23 +03:00
parent 915e6107d1
commit 4742057b51
9 changed files with 84 additions and 5 deletions
@@ -0,0 +1,32 @@
// IGNORE_BACKEND_FIR: JVM_IR
// IGNORE_BACKEND: JS
// WITH_RUNTIME
// WITH_COROUTINES
// COMMON_COROUTINES_TEST
import helpers.*
import COROUTINES_PACKAGE.*
import COROUTINES_PACKAGE.intrinsics.*
inline fun callAction(aux: Int, action: () -> String): String {
return action()
}
suspend fun get() = "OK"
suspend fun callSuspend(): String {
return callAction(action = {
get()
}, aux = 0)
}
fun builder(c: suspend () -> Unit) {
c.startCoroutine(EmptyContinuation)
}
fun box(): String {
var v = "fail"
builder {
v = callSuspend()
}
return v
}