[IR BE] Remap references in default arg value in inner class constructor
Make sure that there is no reference into zombie declarations. - fix KT-40771 - add test
This commit is contained in:
Generated
+5
@@ -15055,6 +15055,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
|||||||
runTest("compiler/testData/codegen/box/innerNested/innerSimple.kt");
|
runTest("compiler/testData/codegen/box/innerNested/innerSimple.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("innerWithDefaultArgument.kt")
|
||||||
|
public void testInnerWithDefaultArgument() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/innerNested/innerWithDefaultArgument.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt3132.kt")
|
@TestMetadata("kt3132.kt")
|
||||||
public void testKt3132() throws Exception {
|
public void testKt3132() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/innerNested/kt3132.kt");
|
runTest("compiler/testData/codegen/box/innerNested/kt3132.kt");
|
||||||
|
|||||||
+2
-1
@@ -46,10 +46,11 @@ class InnerClassesLowering(val context: BackendContext, private val innerClasses
|
|||||||
|
|
||||||
val newConstructor = lowerConstructor(declaration)
|
val newConstructor = lowerConstructor(declaration)
|
||||||
val oldConstructorParameterToNew = innerClassesSupport.primaryConstructorParameterMap(declaration)
|
val oldConstructorParameterToNew = innerClassesSupport.primaryConstructorParameterMap(declaration)
|
||||||
|
val variableRemapper = VariableRemapper(oldConstructorParameterToNew)
|
||||||
for ((oldParam, newParam) in oldConstructorParameterToNew.entries) {
|
for ((oldParam, newParam) in oldConstructorParameterToNew.entries) {
|
||||||
newParam.defaultValue = oldParam.defaultValue?.let { oldDefault ->
|
newParam.defaultValue = oldParam.defaultValue?.let { oldDefault ->
|
||||||
context.irFactory.createExpressionBody(oldDefault.startOffset, oldDefault.endOffset) {
|
context.irFactory.createExpressionBody(oldDefault.startOffset, oldDefault.endOffset) {
|
||||||
expression = oldDefault.expression.patchDeclarationParents(newConstructor)
|
expression = oldDefault.expression.transform(variableRemapper, null).patchDeclarationParents(newConstructor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
|
||||||
|
// KT-40771
|
||||||
|
|
||||||
|
|
||||||
|
class Outer(val o: String, val oo: String = o) {
|
||||||
|
inner class Inner(val k: String, val kk: String = k)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
val o = Outer("O")
|
||||||
|
val i = o.Inner("K")
|
||||||
|
|
||||||
|
return o.oo + i.kk
|
||||||
|
}
|
||||||
+5
@@ -16450,6 +16450,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/box/innerNested/innerSimple.kt");
|
runTest("compiler/testData/codegen/box/innerNested/innerSimple.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("innerWithDefaultArgument.kt")
|
||||||
|
public void testInnerWithDefaultArgument() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/innerNested/innerWithDefaultArgument.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt3132.kt")
|
@TestMetadata("kt3132.kt")
|
||||||
public void testKt3132() throws Exception {
|
public void testKt3132() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/innerNested/kt3132.kt");
|
runTest("compiler/testData/codegen/box/innerNested/kt3132.kt");
|
||||||
|
|||||||
+5
@@ -16450,6 +16450,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
runTest("compiler/testData/codegen/box/innerNested/innerSimple.kt");
|
runTest("compiler/testData/codegen/box/innerNested/innerSimple.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("innerWithDefaultArgument.kt")
|
||||||
|
public void testInnerWithDefaultArgument() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/innerNested/innerWithDefaultArgument.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt3132.kt")
|
@TestMetadata("kt3132.kt")
|
||||||
public void testKt3132() throws Exception {
|
public void testKt3132() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/innerNested/kt3132.kt");
|
runTest("compiler/testData/codegen/box/innerNested/kt3132.kt");
|
||||||
|
|||||||
+5
@@ -15055,6 +15055,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/innerNested/innerSimple.kt");
|
runTest("compiler/testData/codegen/box/innerNested/innerSimple.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("innerWithDefaultArgument.kt")
|
||||||
|
public void testInnerWithDefaultArgument() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/innerNested/innerWithDefaultArgument.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt3132.kt")
|
@TestMetadata("kt3132.kt")
|
||||||
public void testKt3132() throws Exception {
|
public void testKt3132() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/innerNested/kt3132.kt");
|
runTest("compiler/testData/codegen/box/innerNested/kt3132.kt");
|
||||||
|
|||||||
Generated
+5
@@ -13055,6 +13055,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
|
|||||||
runTest("compiler/testData/codegen/box/innerNested/innerSimple.kt");
|
runTest("compiler/testData/codegen/box/innerNested/innerSimple.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("innerWithDefaultArgument.kt")
|
||||||
|
public void testInnerWithDefaultArgument() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/innerNested/innerWithDefaultArgument.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt3132.kt")
|
@TestMetadata("kt3132.kt")
|
||||||
public void testKt3132() throws Exception {
|
public void testKt3132() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/innerNested/kt3132.kt");
|
runTest("compiler/testData/codegen/box/innerNested/kt3132.kt");
|
||||||
|
|||||||
Generated
+5
@@ -13055,6 +13055,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/innerNested/innerSimple.kt");
|
runTest("compiler/testData/codegen/box/innerNested/innerSimple.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("innerWithDefaultArgument.kt")
|
||||||
|
public void testInnerWithDefaultArgument() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/innerNested/innerWithDefaultArgument.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt3132.kt")
|
@TestMetadata("kt3132.kt")
|
||||||
public void testKt3132() throws Exception {
|
public void testKt3132() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/innerNested/kt3132.kt");
|
runTest("compiler/testData/codegen/box/innerNested/kt3132.kt");
|
||||||
|
|||||||
+5
@@ -13120,6 +13120,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/innerNested/innerSimple.kt");
|
runTest("compiler/testData/codegen/box/innerNested/innerSimple.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("innerWithDefaultArgument.kt")
|
||||||
|
public void testInnerWithDefaultArgument() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/innerNested/innerWithDefaultArgument.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt3132.kt")
|
@TestMetadata("kt3132.kt")
|
||||||
public void testKt3132() throws Exception {
|
public void testKt3132() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/innerNested/kt3132.kt");
|
runTest("compiler/testData/codegen/box/innerNested/kt3132.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user