Fix super constructor calls of anonymous objects and local classes
If a class inherits from another class which captures something (outer class instance, receiver parameter, local variables, etc.), the constructor of the former class should contain all the parameters of the super constructor as its own parameters, so that it could make a proper super call. All such parameters are now replicated in the derived constructor with kind = SUPER_CALL_PARAM, except an instance of the outer class (kind = OUTER), which can be taken from the derived's own OUTER when it has one, to prevent multiple passing of the same argument. Previously it worked only when inheriting from inner classes via a special hack (ConstructorFrameMap). Also reuse recently introduced ArgumentGenerator to automatically take care of default and vararg arguments of super constructor #KT-3581 Fixed #KT-5342 Fixed #KT-5343 Fixed
This commit is contained in:
+75
-1
@@ -31,7 +31,7 @@ import org.jetbrains.jet.codegen.generated.AbstractBlackBoxCodegenTest;
|
||||
/** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("compiler/testData/codegen/box")
|
||||
@InnerTestClasses({BlackBoxCodegenTestGenerated.Arrays.class, BlackBoxCodegenTestGenerated.BinaryOp.class, BlackBoxCodegenTestGenerated.Bridges.class, BlackBoxCodegenTestGenerated.BuiltinStubMethods.class, BlackBoxCodegenTestGenerated.Casts.class, BlackBoxCodegenTestGenerated.Classes.class, BlackBoxCodegenTestGenerated.Closures.class, BlackBoxCodegenTestGenerated.Constants.class, BlackBoxCodegenTestGenerated.ControlStructures.class, BlackBoxCodegenTestGenerated.DefaultArguments.class, BlackBoxCodegenTestGenerated.DelegatedProperty.class, BlackBoxCodegenTestGenerated.Elvis.class, BlackBoxCodegenTestGenerated.Enum.class, BlackBoxCodegenTestGenerated.ExclExcl.class, BlackBoxCodegenTestGenerated.ExtensionFunctions.class, BlackBoxCodegenTestGenerated.ExtensionProperties.class, BlackBoxCodegenTestGenerated.FakeOverride.class, BlackBoxCodegenTestGenerated.FieldRename.class, BlackBoxCodegenTestGenerated.Finally.class, BlackBoxCodegenTestGenerated.Functions.class, BlackBoxCodegenTestGenerated.InnerNested.class, BlackBoxCodegenTestGenerated.Instructions.class, BlackBoxCodegenTestGenerated.Intrinsics.class, BlackBoxCodegenTestGenerated.Labels.class, BlackBoxCodegenTestGenerated.LocalClasses.class, BlackBoxCodegenTestGenerated.MultiDecl.class, BlackBoxCodegenTestGenerated.Objects.class, BlackBoxCodegenTestGenerated.OperatorConventions.class, BlackBoxCodegenTestGenerated.Package.class, BlackBoxCodegenTestGenerated.PrimitiveTypes.class, BlackBoxCodegenTestGenerated.Properties.class, BlackBoxCodegenTestGenerated.Reflection.class, BlackBoxCodegenTestGenerated.Regressions.class, BlackBoxCodegenTestGenerated.SafeCall.class, BlackBoxCodegenTestGenerated.SamConstructors.class, BlackBoxCodegenTestGenerated.Strings.class, BlackBoxCodegenTestGenerated.Super.class, BlackBoxCodegenTestGenerated.ToArray.class, BlackBoxCodegenTestGenerated.Traits.class, BlackBoxCodegenTestGenerated.TypeInfo.class, BlackBoxCodegenTestGenerated.TypeMapping.class, BlackBoxCodegenTestGenerated.UnaryOp.class, BlackBoxCodegenTestGenerated.Unit.class, BlackBoxCodegenTestGenerated.Vararg.class, BlackBoxCodegenTestGenerated.When.class})
|
||||
@InnerTestClasses({BlackBoxCodegenTestGenerated.Arrays.class, BlackBoxCodegenTestGenerated.BinaryOp.class, BlackBoxCodegenTestGenerated.Bridges.class, BlackBoxCodegenTestGenerated.BuiltinStubMethods.class, BlackBoxCodegenTestGenerated.Casts.class, BlackBoxCodegenTestGenerated.Classes.class, BlackBoxCodegenTestGenerated.Closures.class, BlackBoxCodegenTestGenerated.Constants.class, BlackBoxCodegenTestGenerated.ControlStructures.class, BlackBoxCodegenTestGenerated.DefaultArguments.class, BlackBoxCodegenTestGenerated.DelegatedProperty.class, BlackBoxCodegenTestGenerated.Elvis.class, BlackBoxCodegenTestGenerated.Enum.class, BlackBoxCodegenTestGenerated.ExclExcl.class, BlackBoxCodegenTestGenerated.ExtensionFunctions.class, BlackBoxCodegenTestGenerated.ExtensionProperties.class, BlackBoxCodegenTestGenerated.FakeOverride.class, BlackBoxCodegenTestGenerated.FieldRename.class, BlackBoxCodegenTestGenerated.Finally.class, BlackBoxCodegenTestGenerated.Functions.class, BlackBoxCodegenTestGenerated.InnerNested.class, BlackBoxCodegenTestGenerated.Instructions.class, BlackBoxCodegenTestGenerated.Intrinsics.class, BlackBoxCodegenTestGenerated.Labels.class, BlackBoxCodegenTestGenerated.LocalClasses.class, BlackBoxCodegenTestGenerated.MultiDecl.class, BlackBoxCodegenTestGenerated.Objects.class, BlackBoxCodegenTestGenerated.OperatorConventions.class, BlackBoxCodegenTestGenerated.Package.class, BlackBoxCodegenTestGenerated.PrimitiveTypes.class, BlackBoxCodegenTestGenerated.Properties.class, BlackBoxCodegenTestGenerated.Reflection.class, BlackBoxCodegenTestGenerated.Regressions.class, BlackBoxCodegenTestGenerated.SafeCall.class, BlackBoxCodegenTestGenerated.SamConstructors.class, BlackBoxCodegenTestGenerated.Strings.class, BlackBoxCodegenTestGenerated.Super.class, BlackBoxCodegenTestGenerated.SuperConstructorCall.class, BlackBoxCodegenTestGenerated.ToArray.class, BlackBoxCodegenTestGenerated.Traits.class, BlackBoxCodegenTestGenerated.TypeInfo.class, BlackBoxCodegenTestGenerated.TypeMapping.class, BlackBoxCodegenTestGenerated.UnaryOp.class, BlackBoxCodegenTestGenerated.Unit.class, BlackBoxCodegenTestGenerated.Vararg.class, BlackBoxCodegenTestGenerated.When.class})
|
||||
public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
public void testAllFilesPresentInBox() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/codegen/box"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
@@ -4826,6 +4826,79 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/superConstructorCall")
|
||||
public static class SuperConstructorCall extends AbstractBlackBoxCodegenTest {
|
||||
public void testAllFilesPresentInSuperConstructorCall() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/codegen/box/superConstructorCall"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("deepInnerHierarchy.kt")
|
||||
public void testDeepInnerHierarchy() throws Exception {
|
||||
doTest("compiler/testData/codegen/box/superConstructorCall/deepInnerHierarchy.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("deepLocalHierarchy.kt")
|
||||
public void testDeepLocalHierarchy() throws Exception {
|
||||
doTest("compiler/testData/codegen/box/superConstructorCall/deepLocalHierarchy.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("innerExtendsOuter.kt")
|
||||
public void testInnerExtendsOuter() throws Exception {
|
||||
doTest("compiler/testData/codegen/box/superConstructorCall/innerExtendsOuter.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("localExtendsLocalWithClosure.kt")
|
||||
public void testLocalExtendsLocalWithClosure() throws Exception {
|
||||
doTest("compiler/testData/codegen/box/superConstructorCall/localExtendsLocalWithClosure.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("localWithClosureExtendsLocalWithClosure.kt")
|
||||
public void testLocalWithClosureExtendsLocalWithClosure() throws Exception {
|
||||
doTest("compiler/testData/codegen/box/superConstructorCall/localWithClosureExtendsLocalWithClosure.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("objectExtendsClassDefaultArgument.kt")
|
||||
public void testObjectExtendsClassDefaultArgument() throws Exception {
|
||||
doTest("compiler/testData/codegen/box/superConstructorCall/objectExtendsClassDefaultArgument.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("objectExtendsClassVararg.kt")
|
||||
public void testObjectExtendsClassVararg() throws Exception {
|
||||
doTest("compiler/testData/codegen/box/superConstructorCall/objectExtendsClassVararg.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("objectExtendsInner.kt")
|
||||
public void testObjectExtendsInner() throws Exception {
|
||||
doTest("compiler/testData/codegen/box/superConstructorCall/objectExtendsInner.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("objectExtendsInnerDefaultArgument.kt")
|
||||
public void testObjectExtendsInnerDefaultArgument() throws Exception {
|
||||
doTest("compiler/testData/codegen/box/superConstructorCall/objectExtendsInnerDefaultArgument.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("objectExtendsInnerOfLocalVarargAndDefault.kt")
|
||||
public void testObjectExtendsInnerOfLocalVarargAndDefault() throws Exception {
|
||||
doTest("compiler/testData/codegen/box/superConstructorCall/objectExtendsInnerOfLocalVarargAndDefault.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("objectExtendsInnerOfLocalWithCapture.kt")
|
||||
public void testObjectExtendsInnerOfLocalWithCapture() throws Exception {
|
||||
doTest("compiler/testData/codegen/box/superConstructorCall/objectExtendsInnerOfLocalWithCapture.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("objectExtendsLocalCaptureInSuperCall.kt")
|
||||
public void testObjectExtendsLocalCaptureInSuperCall() throws Exception {
|
||||
doTest("compiler/testData/codegen/box/superConstructorCall/objectExtendsLocalCaptureInSuperCall.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("objectExtendsLocalWithClosure.kt")
|
||||
public void testObjectExtendsLocalWithClosure() throws Exception {
|
||||
doTest("compiler/testData/codegen/box/superConstructorCall/objectExtendsLocalWithClosure.kt");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/toArray")
|
||||
public static class ToArray extends AbstractBlackBoxCodegenTest {
|
||||
public void testAllFilesPresentInToArray() throws Exception {
|
||||
@@ -5335,6 +5408,7 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
suite.addTestSuite(SamConstructors.class);
|
||||
suite.addTestSuite(Strings.class);
|
||||
suite.addTestSuite(Super.class);
|
||||
suite.addTestSuite(SuperConstructorCall.class);
|
||||
suite.addTestSuite(ToArray.class);
|
||||
suite.addTest(Traits.innerSuite());
|
||||
suite.addTestSuite(TypeInfo.class);
|
||||
|
||||
Reference in New Issue
Block a user