IR KT-50039 don't initialize outer 'this' in delegating constructor

This commit is contained in:
Dmitry Petrov
2021-12-03 12:06:42 +03:00
committed by teamcity
parent 0f745032af
commit 7206c06d26
11 changed files with 82 additions and 2 deletions
@@ -10,3 +10,8 @@ class A {
}
fun box() = A().box()
// CHECK_BYTECODE_TEXT
// 1 PUTFIELD A\$Inner\.this\$0 : LA;
// ^ A$Inner.this$0 SHOULD be written in primary constructor of A$Inner,
// and SHOULD NOT be written in corresponding default arguments stub.
@@ -0,0 +1,17 @@
class Outer(val outer: String) {
open inner class Inner(val inner: String) {
constructor() : this("K")
fun test() = outer + inner
}
fun obj(): Inner =
object : Inner() {}
}
fun box() = Outer("O").obj().test()
// CHECK_BYTECODE_TEXT
// 1 PUTFIELD Outer\$Inner\.this\$0 : LOuter;
// ^ Outer$Inner.this$0 SHOULD be written in primary constructor of Outer$Inner,
// and SHOULD NOT be written in delegating constructor.