Copy nested objects of default lambda during inline

This commit is contained in:
Mikhael Bogdanov
2017-12-20 14:05:33 +01:00
parent 3513f1a86a
commit f4f7c83eeb
10 changed files with 392 additions and 181 deletions
@@ -0,0 +1,20 @@
// TARGET_BACKEND: JVM
// FILE: A.kt
package test
inline fun test(s: () -> () -> String = { val z = "Outer"; { "OK" } }) =
s()
val same = test()
// FILE: B.kt
import test.*
fun box(): String {
val inlined = test()
if (same::class.java == inlined::class.java) return "fail 1 : ${same::class.java} == ${inlined::class.java}"
println (inlined::class.java)
return inlined()
}
@@ -0,0 +1,20 @@
// TARGET_BACKEND: JVM
// FILE: A.kt
package test
inline fun test(s: () -> () -> () -> String = { val z = "Outer"; { { "OK" } } }) =
s()
val same = test()
// FILE: B.kt
import test.*
fun box(): String {
val inlined = test()
if (same::class.java == inlined::class.java) return "fail 1 : ${same::class.java} == ${inlined::class.java}"
if (same()::class.java == inlined()::class.java) return "fail 2 : ${same()::class.java} == ${inlined()::class.java}"
return inlined()()
}