From 55382ba848ca75107b5c519da383b19f666a8f3c Mon Sep 17 00:00:00 2001 From: Michael Bogdanov Date: Thu, 21 Jul 2016 10:51:22 +0300 Subject: [PATCH] Removed obsolete code in 'lookupConstructorExpressionsInClosureIfPresent' method --- .../codegen/ImplementationBodyCodegen.java | 16 ------- ...innerExtendsInnerViaSecondaryConstuctor.kt | 17 ++++++++ ...innerExtendsInnerWithProperOuterCapture.kt | 17 ++++++++ .../superConstructorCall/localExtendsInner.kt | 23 ++++++++++ .../codegen/BlackBoxCodegenTestGenerated.java | 42 +++++++++++++------ .../semantics/InnerNestedTestGenerated.java | 12 ------ 6 files changed, 87 insertions(+), 40 deletions(-) create mode 100644 compiler/testData/codegen/box/superConstructorCall/innerExtendsInnerViaSecondaryConstuctor.kt create mode 100644 compiler/testData/codegen/box/superConstructorCall/innerExtendsInnerWithProperOuterCapture.kt create mode 100644 compiler/testData/codegen/box/superConstructorCall/localExtendsInner.kt diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ImplementationBodyCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ImplementationBodyCodegen.java index 180c6914e57..2bf1b7c391c 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ImplementationBodyCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ImplementationBodyCodegen.java @@ -1309,22 +1309,6 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { specifier.accept(visitor); } } - - ClassDescriptor superClass = DescriptorUtilsKt.getSuperClassNotAny(descriptor); - if (superClass != null) { - if (superClass.isInner()) { - context.lookupInContext(superClass.getContainingDeclaration(), StackValue.LOCAL_0, state, true); - } - - ConstructorDescriptor primaryConstructor = descriptor.getUnsubstitutedPrimaryConstructor(); - if (primaryConstructor != null && !isAnonymousObject(descriptor)) { - ResolvedCall delegationCall = getDelegationConstructorCall(bindingContext, primaryConstructor); - KtValueArgumentList argumentList = delegationCall != null ? delegationCall.getCall().getValueArgumentList() : null; - if (argumentList != null) { - argumentList.accept(visitor); - } - } - } } private void generateTraitMethods() { diff --git a/compiler/testData/codegen/box/superConstructorCall/innerExtendsInnerViaSecondaryConstuctor.kt b/compiler/testData/codegen/box/superConstructorCall/innerExtendsInnerViaSecondaryConstuctor.kt new file mode 100644 index 00000000000..c218f292c1f --- /dev/null +++ b/compiler/testData/codegen/box/superConstructorCall/innerExtendsInnerViaSecondaryConstuctor.kt @@ -0,0 +1,17 @@ +open class Father(val param: String) { + abstract inner class InClass { + fun work(): String { + return param + } + } + + inner class Child(p: String) : Father(p) { + inner class Child2 : Father.InClass { + constructor(): super() + } + } +} + +fun box(): String { + return Father("fail").Child("OK").Child2().work() +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/superConstructorCall/innerExtendsInnerWithProperOuterCapture.kt b/compiler/testData/codegen/box/superConstructorCall/innerExtendsInnerWithProperOuterCapture.kt new file mode 100644 index 00000000000..3dd19c2f3d5 --- /dev/null +++ b/compiler/testData/codegen/box/superConstructorCall/innerExtendsInnerWithProperOuterCapture.kt @@ -0,0 +1,17 @@ +open class Father(val param: String) { + abstract inner class InClass { + fun work(): String { + return param + } + } + + inner class Child(p: String) : Father(p) { + inner class Child2 : Father.InClass() { + + } + } +} + +fun box(): String { + return Father("fail").Child("OK").Child2().work() +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/superConstructorCall/localExtendsInner.kt b/compiler/testData/codegen/box/superConstructorCall/localExtendsInner.kt new file mode 100644 index 00000000000..32c42af614d --- /dev/null +++ b/compiler/testData/codegen/box/superConstructorCall/localExtendsInner.kt @@ -0,0 +1,23 @@ +// TARGET_BACKEND: JVM + +open class Father(val param: String) { + abstract inner class InClass { + fun work(): String { + return param + } + } + + inner class Child(p: String) : Father(p) { + fun test(): InClass { + class Local : Father.InClass() { + + } + return Local() + } + + } +} + +fun box(): String { + return Father("fail").Child("OK").test().work() +} \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index 16ecf5bdbf3..68911f1e1f2 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -7321,18 +7321,6 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { doTest(fileName); } - @TestMetadata("kt11833_1.kt") - public void testKt11833_1() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/innerNested/kt11833_1.kt"); - doTest(fileName); - } - - @TestMetadata("kt11833_2.kt") - public void testKt11833_2() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/innerNested/kt11833_2.kt"); - doTest(fileName); - } - @TestMetadata("kt3132.kt") public void testKt3132() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/innerNested/kt3132.kt"); @@ -14347,18 +14335,48 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { doTest(fileName); } + @TestMetadata("innerExtendsInnerViaSecondaryConstuctor.kt") + public void testInnerExtendsInnerViaSecondaryConstuctor() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/superConstructorCall/innerExtendsInnerViaSecondaryConstuctor.kt"); + doTest(fileName); + } + + @TestMetadata("innerExtendsInnerWithProperOuterCapture.kt") + public void testInnerExtendsInnerWithProperOuterCapture() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/superConstructorCall/innerExtendsInnerWithProperOuterCapture.kt"); + doTest(fileName); + } + @TestMetadata("innerExtendsOuter.kt") public void testInnerExtendsOuter() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/superConstructorCall/innerExtendsOuter.kt"); doTest(fileName); } + @TestMetadata("kt11833_1.kt") + public void testKt11833_1() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/superConstructorCall/kt11833_1.kt"); + doTest(fileName); + } + + @TestMetadata("kt11833_2.kt") + public void testKt11833_2() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/superConstructorCall/kt11833_2.kt"); + doTest(fileName); + } + @TestMetadata("localClassOuterDiffersFromInnerOuter.kt") public void testLocalClassOuterDiffersFromInnerOuter() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/superConstructorCall/localClassOuterDiffersFromInnerOuter.kt"); doTest(fileName); } + @TestMetadata("localExtendsInner.kt") + public void testLocalExtendsInner() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/superConstructorCall/localExtendsInner.kt"); + doTest(fileName); + } + @TestMetadata("localExtendsLocalWithClosure.kt") public void testLocalExtendsLocalWithClosure() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/superConstructorCall/localExtendsLocalWithClosure.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/InnerNestedTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/InnerNestedTestGenerated.java index 7d937271f91..dd9cc2c7670 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/InnerNestedTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/InnerNestedTestGenerated.java @@ -107,18 +107,6 @@ public class InnerNestedTestGenerated extends AbstractInnerNestedTest { doTest(fileName); } - @TestMetadata("kt11833_1.kt") - public void testKt11833_1() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/innerNested/kt11833_1.kt"); - doTest(fileName); - } - - @TestMetadata("kt11833_2.kt") - public void testKt11833_2() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/innerNested/kt11833_2.kt"); - doTest(fileName); - } - @TestMetadata("kt3132.kt") public void testKt3132() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/innerNested/kt3132.kt");