JVM IR: skip temporary variables in InventNamesForLocalClasses
This commit is contained in:
+9
@@ -88,6 +88,15 @@ class InventNamesForLocalClasses(private val context: JvmBackendContext) : FileL
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We explicitly skip temporary variables (such as a for loop iterator, or a temporary value for an elvis operator)
|
||||||
|
// because they are not present in the original source code and their names should not affect names of local entities.
|
||||||
|
if (declaration.origin == IrDeclarationOrigin.FOR_LOOP_ITERATOR ||
|
||||||
|
declaration.origin == IrDeclarationOrigin.IR_TEMPORARY_VARIABLE
|
||||||
|
) {
|
||||||
|
declaration.acceptChildren(this, data)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
val enclosingName = data.enclosingName
|
val enclosingName = data.enclosingName
|
||||||
val simpleName = declaration.name.asString()
|
val simpleName = declaration.name.asString()
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
// WITH_RUNTIME
|
||||||
|
// KJS_WITH_FULL_RUNTIME
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
var result = ""
|
||||||
|
for (x in listOf('O', 'A', 'K').filter { it > 'D' }) {
|
||||||
|
result += object { fun run() = x }.run()
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fun box(): String {
|
||||||
|
return (object { val r = "OK" } ?: null)!!.r
|
||||||
|
}
|
||||||
+10
@@ -13789,6 +13789,16 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/ir"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/ir"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("anonymousObjectInForLoopIteratorAndBody.kt")
|
||||||
|
public void testAnonymousObjectInForLoopIteratorAndBody() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/ir/anonymousObjectInForLoopIteratorAndBody.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("anonymousObjectInsideElvis.kt")
|
||||||
|
public void testAnonymousObjectInsideElvis() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/ir/anonymousObjectInsideElvis.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("classInitializers.kt")
|
@TestMetadata("classInitializers.kt")
|
||||||
public void testClassInitializers() throws Exception {
|
public void testClassInitializers() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/ir/classInitializers.kt");
|
runTest("compiler/testData/codegen/box/ir/classInitializers.kt");
|
||||||
|
|||||||
+10
@@ -13789,6 +13789,16 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/ir"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/ir"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("anonymousObjectInForLoopIteratorAndBody.kt")
|
||||||
|
public void testAnonymousObjectInForLoopIteratorAndBody() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/ir/anonymousObjectInForLoopIteratorAndBody.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("anonymousObjectInsideElvis.kt")
|
||||||
|
public void testAnonymousObjectInsideElvis() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/ir/anonymousObjectInsideElvis.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("classInitializers.kt")
|
@TestMetadata("classInitializers.kt")
|
||||||
public void testClassInitializers() throws Exception {
|
public void testClassInitializers() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/ir/classInitializers.kt");
|
runTest("compiler/testData/codegen/box/ir/classInitializers.kt");
|
||||||
|
|||||||
+10
@@ -12674,6 +12674,16 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/ir"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM_IR, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/ir"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM_IR, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("anonymousObjectInForLoopIteratorAndBody.kt")
|
||||||
|
public void testAnonymousObjectInForLoopIteratorAndBody() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/ir/anonymousObjectInForLoopIteratorAndBody.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("anonymousObjectInsideElvis.kt")
|
||||||
|
public void testAnonymousObjectInsideElvis() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/ir/anonymousObjectInsideElvis.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("classInitializers.kt")
|
@TestMetadata("classInitializers.kt")
|
||||||
public void testClassInitializers() throws Exception {
|
public void testClassInitializers() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/ir/classInitializers.kt");
|
runTest("compiler/testData/codegen/box/ir/classInitializers.kt");
|
||||||
|
|||||||
Generated
+10
@@ -11014,6 +11014,16 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
|||||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/ir"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS_IR, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/ir"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS_IR, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("anonymousObjectInForLoopIteratorAndBody.kt")
|
||||||
|
public void testAnonymousObjectInForLoopIteratorAndBody() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/ir/anonymousObjectInForLoopIteratorAndBody.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("anonymousObjectInsideElvis.kt")
|
||||||
|
public void testAnonymousObjectInsideElvis() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/ir/anonymousObjectInsideElvis.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("classInitializers.kt")
|
@TestMetadata("classInitializers.kt")
|
||||||
public void testClassInitializers() throws Exception {
|
public void testClassInitializers() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/ir/classInitializers.kt");
|
runTest("compiler/testData/codegen/box/ir/classInitializers.kt");
|
||||||
|
|||||||
+10
@@ -12169,6 +12169,16 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
|||||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/ir"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/ir"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("anonymousObjectInForLoopIteratorAndBody.kt")
|
||||||
|
public void testAnonymousObjectInForLoopIteratorAndBody() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/ir/anonymousObjectInForLoopIteratorAndBody.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("anonymousObjectInsideElvis.kt")
|
||||||
|
public void testAnonymousObjectInsideElvis() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/ir/anonymousObjectInsideElvis.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("classInitializers.kt")
|
@TestMetadata("classInitializers.kt")
|
||||||
public void testClassInitializers() throws Exception {
|
public void testClassInitializers() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/ir/classInitializers.kt");
|
runTest("compiler/testData/codegen/box/ir/classInitializers.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user