JVM: rename this$0 when regenerating nested objects too

In the old backend, this was unnecessary because nested objects would
reference their lambdas' captures through the original this$0. On
JVM_IR, using loose capture fields means a name/descriptor clash can
occur on any level of nesting, not just the top.
This commit is contained in:
pyos
2021-02-03 14:52:14 +01:00
committed by max-kammerer
parent ec89cb2313
commit 1310a65f0c
13 changed files with 180 additions and 56 deletions
@@ -0,0 +1,14 @@
// FILE: 1.kt
package test
class C(val x: String) {
fun f(y: String) = C(y).g { x }
inline fun g(crossinline h: () -> String) =
{ { h() + x }() }()
}
// FILE: 2.kt
import test.*
fun box() = C("O").f("K")
@@ -0,0 +1,14 @@
// FILE: 1.kt
package test
class C(val x: String) {
inline fun f(crossinline h: () -> String) = C("").g { x + h() }
inline fun g(crossinline h: () -> String) =
{ { h() + x }() }()
}
// FILE: 2.kt
import test.*
fun box() = C("O").f { "K" }