JVM IR: Fix compilation of nested inner classes

This commit is contained in:
Steven Schäfer
2020-08-28 13:43:52 +02:00
committed by Alexander Udalov
parent 02e78bcd76
commit b02f0f0a25
9 changed files with 49 additions and 1 deletions
@@ -14478,6 +14478,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/innerNested/nestedInPackage.kt");
}
@TestMetadata("nestedInnerClass.kt")
public void testNestedInnerClass() throws Exception {
runTest("compiler/testData/codegen/box/innerNested/nestedInnerClass.kt");
}
@TestMetadata("nestedObjects.kt")
public void testNestedObjects() throws Exception {
runTest("compiler/testData/codegen/box/innerNested/nestedObjects.kt");
@@ -141,7 +141,7 @@ class InnerClassesMemberBodyLowering(val context: BackendContext, private val in
private fun IrBody.fixThisReference(irClass: IrClass, container: IrDeclaration) {
val enclosingFunction: IrDeclaration? = run {
var current: IrDeclaration? = container
while (current != null && current !is IrFunction) {
while (current != null && current !is IrFunction && current !is IrClass) {
current = current.parent as? IrDeclaration
}
current
@@ -0,0 +1,13 @@
class A(val x: String) {
fun value(): String {
return object {
inner class Y {
val y = x
}
fun value() = Y().y
}.value()
}
}
fun box(): String = A("OK").value()
@@ -15703,6 +15703,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/innerNested/nestedInPackage.kt");
}
@TestMetadata("nestedInnerClass.kt")
public void testNestedInnerClass() throws Exception {
runTest("compiler/testData/codegen/box/innerNested/nestedInnerClass.kt");
}
@TestMetadata("nestedObjects.kt")
public void testNestedObjects() throws Exception {
runTest("compiler/testData/codegen/box/innerNested/nestedObjects.kt");
@@ -15703,6 +15703,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/innerNested/nestedInPackage.kt");
}
@TestMetadata("nestedInnerClass.kt")
public void testNestedInnerClass() throws Exception {
runTest("compiler/testData/codegen/box/innerNested/nestedInnerClass.kt");
}
@TestMetadata("nestedObjects.kt")
public void testNestedObjects() throws Exception {
runTest("compiler/testData/codegen/box/innerNested/nestedObjects.kt");
@@ -14478,6 +14478,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/innerNested/nestedInPackage.kt");
}
@TestMetadata("nestedInnerClass.kt")
public void testNestedInnerClass() throws Exception {
runTest("compiler/testData/codegen/box/innerNested/nestedInnerClass.kt");
}
@TestMetadata("nestedObjects.kt")
public void testNestedObjects() throws Exception {
runTest("compiler/testData/codegen/box/innerNested/nestedObjects.kt");
@@ -12533,6 +12533,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
runTest("compiler/testData/codegen/box/innerNested/nestedInPackage.kt");
}
@TestMetadata("nestedInnerClass.kt")
public void testNestedInnerClass() throws Exception {
runTest("compiler/testData/codegen/box/innerNested/nestedInnerClass.kt");
}
@TestMetadata("nestedObjects.kt")
public void testNestedObjects() throws Exception {
runTest("compiler/testData/codegen/box/innerNested/nestedObjects.kt");
@@ -12533,6 +12533,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/innerNested/nestedInPackage.kt");
}
@TestMetadata("nestedInnerClass.kt")
public void testNestedInnerClass() throws Exception {
runTest("compiler/testData/codegen/box/innerNested/nestedInnerClass.kt");
}
@TestMetadata("nestedObjects.kt")
public void testNestedObjects() throws Exception {
runTest("compiler/testData/codegen/box/innerNested/nestedObjects.kt");
@@ -12598,6 +12598,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/innerNested/nestedInPackage.kt");
}
@TestMetadata("nestedInnerClass.kt")
public void testNestedInnerClass() throws Exception {
runTest("compiler/testData/codegen/box/innerNested/nestedInnerClass.kt");
}
@TestMetadata("nestedObjects.kt")
public void testNestedObjects() throws Exception {
runTest("compiler/testData/codegen/box/innerNested/nestedObjects.kt");