JVM_IR: create temporaries for complex SAM conversion arguments

To avoid bytecode sequences like

    new _1Kt$sam$i$java_lang_Runnable$0
    dup
    new _1Kt$f$1
    dup
    invokespecial _1Kt$f$1.<init>()V
    invokespecial _1Kt$sam$i$java_lang_Runnable$0.<init>(...)V

as the different order of `new` and `<init>` confuses the inliner.
This commit is contained in:
pyos
2019-10-21 14:25:30 +02:00
committed by max-kammerer
parent 650e2501bb
commit 862197d713
6 changed files with 46 additions and 0 deletions
@@ -0,0 +1,16 @@
// IGNORE_BACKEND: JVM_IR
// FILE: 1.kt
package test
inline fun f(crossinline g: () -> Unit) = Runnable(object : () -> Unit {
override fun invoke() = g()
})
// FILE: 2.kt
import test.*
fun box(): String {
var result = "FAIL"
f { result = "OK" }.run()
return result
}