JVM: Rewrite companion object accessor generation
Old version handled only private companions correctly. Some situations require multiple companion object accessors (including accessors for protected companion objects from supertypes) to be generated in the corresponding class.
This commit is contained in:
+73
@@ -17642,6 +17642,79 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/protectedCompanionObjectAccessedFromNestedClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/objects/companionObjectAccess/multipleCompanionsWithAccessors")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class MultipleCompanionsWithAccessors extends AbstractBlackBoxCodegenTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
|
||||
}
|
||||
|
||||
@TestMetadata("accessFromInlineLambda.kt")
|
||||
public void testAccessFromInlineLambda() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/multipleCompanionsWithAccessors/accessFromInlineLambda.kt");
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInMultipleCompanionsWithAccessors() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/objects/companionObjectAccess/multipleCompanionsWithAccessors"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
|
||||
}
|
||||
|
||||
@TestMetadata("anonymousObjectInPropertyInitializer.kt")
|
||||
public void testAnonymousObjectInPropertyInitializer() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/multipleCompanionsWithAccessors/anonymousObjectInPropertyInitializer.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("fromAnonymousObjectInNestedClass.kt")
|
||||
public void testFromAnonymousObjectInNestedClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/multipleCompanionsWithAccessors/fromAnonymousObjectInNestedClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("fromInitBlock.kt")
|
||||
public void testFromInitBlock() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/multipleCompanionsWithAccessors/fromInitBlock.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("fromInitBlockOfNestedClass.kt")
|
||||
public void testFromInitBlockOfNestedClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/multipleCompanionsWithAccessors/fromInitBlockOfNestedClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("fromInlineLambdaInNestedClass.kt")
|
||||
public void testFromInlineLambdaInNestedClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/multipleCompanionsWithAccessors/fromInlineLambdaInNestedClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inheritedProtectedCompanionAndOwnPrivateCompanion.kt")
|
||||
public void testInheritedProtectedCompanionAndOwnPrivateCompanion() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/multipleCompanionsWithAccessors/inheritedProtectedCompanionAndOwnPrivateCompanion.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inheritedProtectedCompanionsReferencedByName.kt")
|
||||
public void testInheritedProtectedCompanionsReferencedByName() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/multipleCompanionsWithAccessors/inheritedProtectedCompanionsReferencedByName.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lambdaInPropertyInitializer.kt")
|
||||
public void testLambdaInPropertyInitializer() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/multipleCompanionsWithAccessors/lambdaInPropertyInitializer.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("twoInheritedProtectedCompanions.kt")
|
||||
public void testTwoInheritedProtectedCompanions() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/multipleCompanionsWithAccessors/twoInheritedProtectedCompanions.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("withCompanionObjectBase.kt")
|
||||
public void testWithCompanionObjectBase() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/multipleCompanionsWithAccessors/withCompanionObjectBase.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("withMultipleNestedCompanionObjectBases.kt")
|
||||
public void testWithMultipleNestedCompanionObjectBases() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/multipleCompanionsWithAccessors/withMultipleNestedCompanionObjectBases.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/objects/companionObjectAccess/primitiveCompanion")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
Reference in New Issue
Block a user