JVM IR: generate enclosing constructor only for lambdas in initializers

There was a typo in JvmLocalClassPopupLowering which allowed the
EnclosingMethod for lambdas and anonymous classes in initializers to
become any function in a class, in case when there was no primary
constructor in that class. E.g. in the added test, `getIrrelevantField`
was the EnclosingMethod of the lambda class before this change.
This commit is contained in:
Alexander Udalov
2020-09-03 18:13:03 +02:00
parent 2ab68b3245
commit 228e329d1f
6 changed files with 88 additions and 1 deletions
@@ -469,6 +469,11 @@ public class BytecodeListingTestGenerated extends AbstractBytecodeListingTest {
runTest("compiler/testData/codegen/bytecodeListing/inline/enclosingInfo/kt10259.kt");
}
@TestMetadata("lambdaInInitBlockNoPrimaryConstructor.kt")
public void testLambdaInInitBlockNoPrimaryConstructor() throws Exception {
runTest("compiler/testData/codegen/bytecodeListing/inline/enclosingInfo/lambdaInInitBlockNoPrimaryConstructor.kt");
}
@TestMetadata("transformedConstructor.kt")
public void testTransformedConstructor() throws Exception {
runTest("compiler/testData/codegen/bytecodeListing/inline/enclosingInfo/transformedConstructor.kt");
@@ -439,6 +439,11 @@ public class IrBytecodeListingTestGenerated extends AbstractIrBytecodeListingTes
runTest("compiler/testData/codegen/bytecodeListing/inline/enclosingInfo/kt10259.kt");
}
@TestMetadata("lambdaInInitBlockNoPrimaryConstructor.kt")
public void testLambdaInInitBlockNoPrimaryConstructor() throws Exception {
runTest("compiler/testData/codegen/bytecodeListing/inline/enclosingInfo/lambdaInInitBlockNoPrimaryConstructor.kt");
}
@TestMetadata("transformedConstructor.kt")
public void testTransformedConstructor() throws Exception {
runTest("compiler/testData/codegen/bytecodeListing/inline/enclosingInfo/transformedConstructor.kt");