Fix initialization of object's INSTANCE$ field

Call object's constructor in <clinit> and ignore the result, but in the first
line of <init> save the current "this" to INSTANCE$

 #KT-4516 Fixed
 #KT-4543 Fixed
 #KT-5291 Fixed
 #KT-5523 Fixed
 #KT-5582 Fixed
This commit is contained in:
Alexander Udalov
2014-09-11 14:19:32 +04:00
parent b907f35995
commit 81004889eb
10 changed files with 175 additions and 34 deletions
@@ -4654,6 +4654,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/objects"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("anonymousObjectPropertyInitialization.kt")
public void testAnonymousObjectPropertyInitialization() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/objects/anonymousObjectPropertyInitialization.kt");
doTest(fileName);
}
@TestMetadata("flist.kt")
public void testFlist() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/objects/flist.kt");
@@ -4768,6 +4774,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
doTest(fileName);
}
@TestMetadata("localFunctionInObjectInitializer_kt4516.kt")
public void testLocalFunctionInObjectInitializer_kt4516() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/objects/localFunctionInObjectInitializer_kt4516.kt");
doTest(fileName);
}
@TestMetadata("methodOnObject.kt")
public void testMethodOnObject() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/objects/methodOnObject.kt");
@@ -4786,6 +4798,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
doTest(fileName);
}
@TestMetadata("objectInitialization_kt5523.kt")
public void testObjectInitialization_kt5523() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/objects/objectInitialization_kt5523.kt");
doTest(fileName);
}
@TestMetadata("objectLiteral.kt")
public void testObjectLiteral() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/objects/objectLiteral.kt");
@@ -4798,6 +4816,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
doTest(fileName);
}
@TestMetadata("objectVsClassInitialization_kt5291.kt")
public void testObjectVsClassInitialization_kt5291() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/objects/objectVsClassInitialization_kt5291.kt");
doTest(fileName);
}
@TestMetadata("objectWithSuperclass.kt")
public void testObjectWithSuperclass() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/objects/objectWithSuperclass.kt");
@@ -4810,6 +4834,18 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
doTest(fileName);
}
@TestMetadata("privateExtensionFromInitializer_kt4543.kt")
public void testPrivateExtensionFromInitializer_kt4543() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/objects/privateExtensionFromInitializer_kt4543.kt");
doTest(fileName);
}
@TestMetadata("privateFunctionFromClosureInInitializer_kt5582.kt")
public void testPrivateFunctionFromClosureInInitializer_kt5582() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/objects/privateFunctionFromClosureInInitializer_kt5582.kt");
doTest(fileName);
}
@TestMetadata("receiverInConstructor.kt")
public void testReceiverInConstructor() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/objects/receiverInConstructor.kt");