Instance field generation in objects

This commit is contained in:
Michael Bogdanov
2015-10-08 12:22:45 +03:00
parent 53ced57c42
commit 60d1736b97
25 changed files with 87 additions and 55 deletions
@@ -0,0 +1,4 @@
public class B {
public static int a = A.INSTANCE$.getC();
public static int b = A.INSTANCE$.foo();
}
@@ -0,0 +1,10 @@
import B
object A {
val c = 1
fun foo() = 4
}
fun box(): String {
return if (B.a == 1 && B.b == 4) "OK" else "${B.a} ${B.b}"
}
@@ -17,6 +17,6 @@ fun test() {
(::local)()
}
// 3 GETSTATIC ConstClosureOptimizationKt\$test\$1\.INSTANCE\$
// 1 GETSTATIC ConstClosureOptimizationKt\$test\$2\.INSTANCE\$
// 1 GETSTATIC ConstClosureOptimizationKt\$test\$3\.INSTANCE\$
// 3 GETSTATIC ConstClosureOptimizationKt\$test\$1\.INSTANCE
// 1 GETSTATIC ConstClosureOptimizationKt\$test\$2\.INSTANCE
// 1 GETSTATIC ConstClosureOptimizationKt\$test\$3\.INSTANCE
@@ -16,4 +16,4 @@ class B {
3 others are for getCONST_VAL
*/
// 5 DEPRECATED
// 6 DEPRECATED
@@ -4,4 +4,4 @@ class A {
}
}
// A and companion object constructor call
// 3 ALOAD 0
// 4 ALOAD 0
@@ -4,5 +4,5 @@ class A {
}
}
// A and companion object constructor call
// 3 ALOAD 0
// 4 ALOAD 0
// 1 synthetic access\$getR
@@ -2,5 +2,5 @@ object A {
val r: Int = 1
}
// Field initialized in constant pool
// A super constructor call and INSTANCE$ put
// 2 ALOAD 0
// A super constructor call, INSTANCE and INSTANCE$ put
// 3 ALOAD 0