Private constructors are now accessed via synthetic constructor with DEFAULT_CONSTRUCTOR_MARKER as an additional argument #KT-6299 Fixed

A set of tests provided. Some external tests fixed accordingly.
Companion object creation changed accordingly.
Derived classes now can use base class with the private constructor.
Refactoring of AccessorForFunctionDescriptor.
This commit is contained in:
Mikhail Glukhikh
2015-06-18 19:52:18 +03:00
parent 83ce674a37
commit 5fabb962ae
28 changed files with 393 additions and 68 deletions
@@ -234,7 +234,7 @@ public abstract class AbstractWriteFlagsTest extends UsefulTestCase {
@Override
public MethodVisitor visitMethod(int access, @NotNull String name, @NotNull String desc, String signature, String[] exceptions) {
if (name.equals(funName)) {
if (name.equals(funName) && (access & Opcodes.ACC_SYNTHETIC) == 0) {
this.access = access;
isExists = true;
}
@@ -5984,6 +5984,75 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
}
}
@TestMetadata("compiler/testData/codegen/box/privateConstructors")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class PrivateConstructors extends AbstractBlackBoxCodegenTest {
public void testAllFilesPresentInPrivateConstructors() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/privateConstructors"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("base.kt")
public void testBase() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/privateConstructors/base.kt");
doTest(fileName);
}
@TestMetadata("companion.kt")
public void testCompanion() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/privateConstructors/companion.kt");
doTest(fileName);
}
@TestMetadata("inline.kt")
public void testInline() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/privateConstructors/inline.kt");
doTest(fileName);
}
@TestMetadata("inner.kt")
public void testInner() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/privateConstructors/inner.kt");
doTest(fileName);
}
@TestMetadata("secondary.kt")
public void testSecondary() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/privateConstructors/secondary.kt");
doTest(fileName);
}
@TestMetadata("withArguments.kt")
public void testWithArguments() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/privateConstructors/withArguments.kt");
doTest(fileName);
}
@TestMetadata("withDefault.kt")
public void testWithDefault() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/privateConstructors/withDefault.kt");
doTest(fileName);
}
@TestMetadata("withLinkedClasses.kt")
public void testWithLinkedClasses() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/privateConstructors/withLinkedClasses.kt");
doTest(fileName);
}
@TestMetadata("withLinkedObjects.kt")
public void testWithLinkedObjects() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/privateConstructors/withLinkedObjects.kt");
doTest(fileName);
}
@TestMetadata("withVarargs.kt")
public void testWithVarargs() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/privateConstructors/withVarargs.kt");
doTest(fileName);
}
}
@TestMetadata("compiler/testData/codegen/box/properties")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -2312,6 +2312,21 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode
}
}
@TestMetadata("compiler/testData/codegen/boxWithStdlib/privateConstructor")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class PrivateConstructor extends AbstractBlackBoxCodegenTest {
public void testAllFilesPresentInPrivateConstructor() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxWithStdlib/privateConstructor"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("synthetic.kt")
public void testSynthetic() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/privateConstructor/synthetic.kt");
doTestWithStdlib(fileName);
}
}
@TestMetadata("compiler/testData/codegen/boxWithStdlib/ranges")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)