diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index fdbc6ed5fd8..31d8d8f3473 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -5482,6 +5482,18 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/closures/kt4137.kt"); } + @Test + @TestMetadata("kt47120.kt") + public void testKt47120() throws Exception { + runTest("compiler/testData/codegen/box/closures/kt47120.kt"); + } + + @Test + @TestMetadata("kt47120a.kt") + public void testKt47120a() throws Exception { + runTest("compiler/testData/codegen/box/closures/kt47120a.kt"); + } + @Test @TestMetadata("kt5589.kt") public void testKt5589() throws Exception { diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/InventNamesForLocalClasses.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/InventNamesForLocalClasses.kt index 20554ada39a..56ba124106e 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/InventNamesForLocalClasses.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/InventNamesForLocalClasses.kt @@ -15,6 +15,7 @@ import org.jetbrains.kotlin.ir.util.isAnonymousObject import org.jetbrains.kotlin.ir.visitors.IrElementVisitor import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.name.NameUtils +import org.jetbrains.kotlin.util.capitalizeDecapitalize.toUpperCaseAsciiOnly abstract class InventNamesForLocalClasses(private val allowTopLevelCallables: Boolean) : FileLoweringPass { @@ -185,8 +186,8 @@ abstract class InventNamesForLocalClasses(private val allowTopLevelCallables: Bo } val simpleName = if (sourceName == null || sourceName.isSpecial) { - val count = (anonymousClassesCount[enclosingName] ?: 0) + 1 - anonymousClassesCount[enclosingName] = count + val count = (anonymousClassesCount[enclosingName.toUpperCaseAsciiOnly()] ?: 0) + 1 + anonymousClassesCount[enclosingName.toUpperCaseAsciiOnly()] = count count.toString() } else { sourceName diff --git a/compiler/testData/codegen/box/closures/kt47120.kt b/compiler/testData/codegen/box/closures/kt47120.kt new file mode 100644 index 00000000000..e34d7af6652 --- /dev/null +++ b/compiler/testData/codegen/box/closures/kt47120.kt @@ -0,0 +1,17 @@ +// TARGET_BACKEND: JVM +// WITH_RUNTIME +// FULL_JDK +import java.util.* + +fun box(): String { + fun f() = {} + fun F() = {} + + val class1 = f().javaClass.name + val class2 = F().javaClass.name + + if (class1.uppercase(Locale.ENGLISH) != class2.uppercase(Locale.ENGLISH)) + return "OK" + else + return "$class1 $class2" +} diff --git a/compiler/testData/codegen/box/closures/kt47120a.kt b/compiler/testData/codegen/box/closures/kt47120a.kt new file mode 100644 index 00000000000..cd9da1ae760 --- /dev/null +++ b/compiler/testData/codegen/box/closures/kt47120a.kt @@ -0,0 +1,24 @@ +// TARGET_BACKEND: JVM +// WITH_RUNTIME +// FULL_JDK +import java.util.* + +fun box(): String { + fun f(): Any { + fun g() = object {} + return g() + } + + fun F(): Any { + fun g() = object {} + return g() + } + + val class1 = f().javaClass.name + val class2 = F().javaClass.name + + if (class1.uppercase(Locale.ENGLISH) != class2.uppercase(Locale.ENGLISH)) + return "OK" + else + return "$class1 $class2" +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index e22d8a3a038..27a8372953d 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -5482,6 +5482,18 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/closures/kt4137.kt"); } + @Test + @TestMetadata("kt47120.kt") + public void testKt47120() throws Exception { + runTest("compiler/testData/codegen/box/closures/kt47120.kt"); + } + + @Test + @TestMetadata("kt47120a.kt") + public void testKt47120a() throws Exception { + runTest("compiler/testData/codegen/box/closures/kt47120a.kt"); + } + @Test @TestMetadata("kt5589.kt") public void testKt5589() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index a77702910a1..0206997fcf0 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -5482,6 +5482,18 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/closures/kt4137.kt"); } + @Test + @TestMetadata("kt47120.kt") + public void testKt47120() throws Exception { + runTest("compiler/testData/codegen/box/closures/kt47120.kt"); + } + + @Test + @TestMetadata("kt47120a.kt") + public void testKt47120a() throws Exception { + runTest("compiler/testData/codegen/box/closures/kt47120a.kt"); + } + @Test @TestMetadata("kt5589.kt") public void testKt5589() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index fcea44f75cb..f8bb6ba2d43 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -4778,6 +4778,16 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/closures/kt4137.kt"); } + @TestMetadata("kt47120.kt") + public void testKt47120() throws Exception { + runTest("compiler/testData/codegen/box/closures/kt47120.kt"); + } + + @TestMetadata("kt47120a.kt") + public void testKt47120a() throws Exception { + runTest("compiler/testData/codegen/box/closures/kt47120a.kt"); + } + @TestMetadata("kt5589.kt") public void testKt5589() throws Exception { runTest("compiler/testData/codegen/box/closures/kt5589.kt");