FIR: Do not build synthetic property named with first capital character

This commit is contained in:
Denis.Zharkov
2021-08-13 18:59:20 +03:00
parent c3a327e118
commit a0553f4dfd
6 changed files with 54 additions and 0 deletions
@@ -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 {
@@ -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<Name>(3)
val standardName = Name.identifier(GETTER_PREFIX + identifier.capitalizeAsciiOnly())
val length = identifier.length
@@ -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()
}
@@ -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 {
@@ -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 {
@@ -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");