KT-11410: Class hierarchy for parts/facade of multi-file class.

Preserve static initialization semantics for parts by introducing a special "clinit trigger" class.
Insert "static initialization trigger" call to every method of a part class, remove this call on inline.
Always mangle names for private functions in multifile class parts to avoid resolution clashes on inheritance.

NB in codegen tests initializers for all non-const vals are wrapped in 'run { ... }',
so that the initializer is not a constant expression, and some static initialization code should be generated.
This commit is contained in:
Dmitry Petrov
2016-03-16 12:06:18 +03:00
parent 0ccaf43e2c
commit db58ebc4b2
34 changed files with 823 additions and 135 deletions
@@ -8469,6 +8469,99 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/multifileClasses/samePartNameDifferentFacades.kt");
doTest(fileName);
}
@TestMetadata("compiler/testData/codegen/box/multifileClasses/optimized")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Optimized extends AbstractBlackBoxCodegenTest {
public void testAllFilesPresentInOptimized() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/multifileClasses/optimized"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("callableRefToFun.kt")
public void testCallableRefToFun() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/multifileClasses/optimized/callableRefToFun.kt");
doTest(fileName);
}
@TestMetadata("callableRefToInternalValInline.kt")
public void testCallableRefToInternalValInline() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/multifileClasses/optimized/callableRefToInternalValInline.kt");
doTest(fileName);
}
@TestMetadata("callableRefToPrivateVal.kt")
public void testCallableRefToPrivateVal() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/multifileClasses/optimized/callableRefToPrivateVal.kt");
doTest(fileName);
}
@TestMetadata("callableRefToVal.kt")
public void testCallableRefToVal() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/multifileClasses/optimized/callableRefToVal.kt");
doTest(fileName);
}
@TestMetadata("calls.kt")
public void testCalls() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/multifileClasses/optimized/calls.kt");
doTest(fileName);
}
@TestMetadata("deferredStaticInitialization.kt")
public void testDeferredStaticInitialization() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/multifileClasses/optimized/deferredStaticInitialization.kt");
doTest(fileName);
}
@TestMetadata("delegatedVal.kt")
public void testDelegatedVal() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/multifileClasses/optimized/delegatedVal.kt");
doTest(fileName);
}
@TestMetadata("initializePrivateVal.kt")
public void testInitializePrivateVal() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/multifileClasses/optimized/initializePrivateVal.kt");
doTest(fileName);
}
@TestMetadata("initializePublicVal.kt")
public void testInitializePublicVal() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/multifileClasses/optimized/initializePublicVal.kt");
doTest(fileName);
}
@TestMetadata("overlappingFuns.kt")
public void testOverlappingFuns() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/multifileClasses/optimized/overlappingFuns.kt");
doTest(fileName);
}
@TestMetadata("overlappingVals.kt")
public void testOverlappingVals() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/multifileClasses/optimized/overlappingVals.kt");
doTest(fileName);
}
@TestMetadata("valAccessFromInlineFunCalledFromJava.kt")
public void testValAccessFromInlineFunCalledFromJava() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/multifileClasses/optimized/valAccessFromInlineFunCalledFromJava.kt");
doTest(fileName);
}
@TestMetadata("valAccessFromInlinedToDifferentPackage.kt")
public void testValAccessFromInlinedToDifferentPackage() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/multifileClasses/optimized/valAccessFromInlinedToDifferentPackage.kt");
doTest(fileName);
}
@TestMetadata("valWithAccessor.kt")
public void testValWithAccessor() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/multifileClasses/optimized/valWithAccessor.kt");
doTest(fileName);
}
}
}
@TestMetadata("compiler/testData/codegen/box/nonLocalReturns")
@@ -916,6 +916,12 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/multifileClasses"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("inlineFromOptimizedMultifileClass.kt")
public void testInlineFromOptimizedMultifileClass() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/multifileClasses/inlineFromOptimizedMultifileClass.kt");
doTest(fileName);
}
@TestMetadata("inlineFromOtherPackage.kt")
public void testInlineFromOtherPackage() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/multifileClasses/inlineFromOtherPackage.kt");
@@ -1007,6 +1007,21 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
}
}
@TestMetadata("compiler/testData/codegen/bytecodeText/multifileClasses")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class MultifileClasses extends AbstractBytecodeTextTest {
public void testAllFilesPresentInMultifileClasses() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/bytecodeText/multifileClasses"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("optimizedMultifileClassFacadeMethods.kt")
public void testOptimizedMultifileClassFacadeMethods() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/multifileClasses/optimizedMultifileClassFacadeMethods.kt");
doTest(fileName);
}
}
@TestMetadata("compiler/testData/codegen/bytecodeText/signature")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -916,6 +916,12 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/multifileClasses"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("inlineFromOptimizedMultifileClass.kt")
public void testInlineFromOptimizedMultifileClass() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/multifileClasses/inlineFromOptimizedMultifileClass.kt");
doTest(fileName);
}
@TestMetadata("inlineFromOtherPackage.kt")
public void testInlineFromOtherPackage() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/multifileClasses/inlineFromOtherPackage.kt");