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
@@ -7,6 +7,8 @@ public final class ClassObjectField {
public ClassObjectField() { /* compiled code */ }
public static final class Companion {
public static final ClassObjectField.Companion INSTANCE;
@org.jetbrains.annotations.Nullable
public final java.lang.String getX() { /* compiled code */ }
@@ -5,8 +5,9 @@ public interface TraitClassObjectField {
static final class Companion {
@org.jetbrains.annotations.Nullable
private final java.lang.String x = "";
private final java.lang.String y = "";
private static final java.lang.String x = "";
private static final java.lang.String y = "";
public static final TraitClassObjectField.Companion INSTANCE;
/**
* @deprecated
@@ -6,6 +6,8 @@ public final class C {
public C() { /* compiled code */ }
public static final class Companion {
public static final C.Companion INSTANCE;
private final java.lang.String getFoo() { /* compiled code */ }
private Companion() { /* compiled code */ }
@@ -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