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 11e74e1423b..763e5039d62 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 @@ -41760,6 +41760,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/syntheticExtensions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test + @TestMetadata("firstCapitalizedProperty.kt") + public void testFirstCapitalizedProperty() throws Exception { + runTest("compiler/testData/codegen/box/syntheticExtensions/firstCapitalizedProperty.kt"); + } + @Test @TestMetadata("fromTwoBases.kt") public void testFromTwoBases() throws Exception { diff --git a/compiler/fir/jvm/src/org/jetbrains/kotlin/fir/resolve/FirJavaSyntheticNamesProvider.kt b/compiler/fir/jvm/src/org/jetbrains/kotlin/fir/resolve/FirJavaSyntheticNamesProvider.kt index b25132646f7..7b90337a9dd 100644 --- a/compiler/fir/jvm/src/org/jetbrains/kotlin/fir/resolve/FirJavaSyntheticNamesProvider.kt +++ b/compiler/fir/jvm/src/org/jetbrains/kotlin/fir/resolve/FirJavaSyntheticNamesProvider.kt @@ -28,6 +28,8 @@ object FirJavaSyntheticNamesProvider : FirSyntheticNamesProvider() { if (name.isSpecial) return emptyList() val identifier = name.identifier if (identifier.isEmpty()) return emptyList() + val firstChar = identifier[0] + if (!firstChar.isJavaIdentifierStart() || firstChar in 'A'..'Z') return emptyList() val result = ArrayList(3) val standardName = Name.identifier(GETTER_PREFIX + identifier.capitalizeAsciiOnly()) val length = identifier.length diff --git a/compiler/testData/codegen/box/syntheticExtensions/firstCapitalizedProperty.kt b/compiler/testData/codegen/box/syntheticExtensions/firstCapitalizedProperty.kt new file mode 100644 index 00000000000..2fc890770d0 --- /dev/null +++ b/compiler/testData/codegen/box/syntheticExtensions/firstCapitalizedProperty.kt @@ -0,0 +1,29 @@ +// TARGET_BACKEND: JVM + +// MODULE: lib + +// FILE: test/UI.java +package test; +public class UI { + public static String foo() { + return "OK"; + } +} + +// FILE: Parent.java +public class Parent { + public String getUI() { return "fail"; } +} + +// MODULE: main(lib) +// FILE: main.kt + +import test.UI; + +class Derived : Parent() { + fun bar(): String = UI.foo() +} + +fun box(): String { + return Derived().bar() +} 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 573ccc8a24c..fa3b995009f 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 @@ -41586,6 +41586,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/syntheticExtensions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); } + @Test + @TestMetadata("firstCapitalizedProperty.kt") + public void testFirstCapitalizedProperty() throws Exception { + runTest("compiler/testData/codegen/box/syntheticExtensions/firstCapitalizedProperty.kt"); + } + @Test @TestMetadata("fromTwoBases.kt") public void testFromTwoBases() 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 c292033aa55..7f20d796240 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 @@ -41760,6 +41760,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/syntheticExtensions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test + @TestMetadata("firstCapitalizedProperty.kt") + public void testFirstCapitalizedProperty() throws Exception { + runTest("compiler/testData/codegen/box/syntheticExtensions/firstCapitalizedProperty.kt"); + } + @Test @TestMetadata("fromTwoBases.kt") public void testFromTwoBases() 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 5e7398cd509..e445345d5af 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -33454,6 +33454,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/syntheticExtensions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); } + @TestMetadata("firstCapitalizedProperty.kt") + public void testFirstCapitalizedProperty() throws Exception { + runTest("compiler/testData/codegen/box/syntheticExtensions/firstCapitalizedProperty.kt"); + } + @TestMetadata("fromTwoBases.kt") public void testFromTwoBases() throws Exception { runTest("compiler/testData/codegen/box/syntheticExtensions/fromTwoBases.kt");