JVM IR: add jvmLocalClassExtractionPhase to lift out local classes from initializers

Otherwise a local class in a field initializer or anonymous init block
is copied into each constructor of the containing class (because
InitializersLowering calls deepCopy).

Since the code structure no longer resembles the original source code
here, record a custom EnclosingMethod mapping before moving such
classes, and use it in codegen.
This commit is contained in:
Alexander Udalov
2019-10-31 16:56:04 +01:00
parent c5159d9cbe
commit 6be9101675
13 changed files with 182 additions and 20 deletions
@@ -23105,6 +23105,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/reflection/enclosing/lambdaInPackage.kt");
}
@TestMetadata("lambdaInPropertyDelegate.kt")
public void testLambdaInPropertyDelegate() throws Exception {
runTest("compiler/testData/codegen/box/reflection/enclosing/lambdaInPropertyDelegate.kt");
}
@TestMetadata("lambdaInPropertyGetter.kt")
public void testLambdaInPropertyGetter() throws Exception {
runTest("compiler/testData/codegen/box/reflection/enclosing/lambdaInPropertyGetter.kt");