FIR: Do not create incorrect synthetic property
This commit is contained in:
+6
@@ -29880,6 +29880,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
||||
runTest("compiler/testData/diagnostics/tests/syntheticExtensions/javaProperties/nonAsciiSecondChar.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nonValidFirstChar.kt")
|
||||
public void testNonValidFirstChar() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/syntheticExtensions/javaProperties/nonValidFirstChar.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("OnlyAscii.kt")
|
||||
public void testOnlyAscii() throws Exception {
|
||||
|
||||
+6
@@ -29880,6 +29880,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
||||
runTest("compiler/testData/diagnostics/tests/syntheticExtensions/javaProperties/nonAsciiSecondChar.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nonValidFirstChar.kt")
|
||||
public void testNonValidFirstChar() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/syntheticExtensions/javaProperties/nonValidFirstChar.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("OnlyAscii.kt")
|
||||
public void testOnlyAscii() throws Exception {
|
||||
|
||||
+6
@@ -29880,6 +29880,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
||||
runTest("compiler/testData/diagnostics/tests/syntheticExtensions/javaProperties/nonAsciiSecondChar.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nonValidFirstChar.kt")
|
||||
public void testNonValidFirstChar() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/syntheticExtensions/javaProperties/nonValidFirstChar.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("OnlyAscii.kt")
|
||||
public void testOnlyAscii() throws Exception {
|
||||
|
||||
+2
-8
@@ -146,17 +146,11 @@ class JavaSyntheticPropertiesScope(
|
||||
name: Name,
|
||||
ownerClass: ClassDescriptor
|
||||
): SyntheticPropertyHolder {
|
||||
if (name.isSpecial) return SyntheticPropertyHolder.EMPTY
|
||||
|
||||
val identifier = name.identifier
|
||||
if (identifier.isEmpty()) return SyntheticPropertyHolder.EMPTY
|
||||
|
||||
val firstChar = identifier[0]
|
||||
if (!firstChar.isJavaIdentifierStart() || firstChar in 'A'..'Z') return SyntheticPropertyHolder.EMPTY
|
||||
val possibleGetMethodNames = possibleGetMethodNames(name)
|
||||
if (possibleGetMethodNames.isEmpty()) return SyntheticPropertyHolder.EMPTY
|
||||
|
||||
val memberScope = ownerClass.unsubstitutedMemberScope
|
||||
|
||||
val possibleGetMethodNames = possibleGetMethodNames(name)
|
||||
val getMethod = possibleGetMethodNames
|
||||
.flatMap { memberScope.getContributedFunctions(it, NoLookupLocation.FROM_SYNTHETIC_SCOPE) }
|
||||
.singleOrNull {
|
||||
|
||||
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
// FIR_IDENTICAL
|
||||
// SKIP_TXT
|
||||
// FILE: A.java
|
||||
public class A {
|
||||
public String get1() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
fun foo(a: A) {
|
||||
a.<!UNRESOLVED_REFERENCE!>`1`<!>
|
||||
a.get1()
|
||||
}
|
||||
Generated
+6
@@ -29976,6 +29976,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/tests/syntheticExtensions/javaProperties/nonAsciiSecondChar.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nonValidFirstChar.kt")
|
||||
public void testNonValidFirstChar() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/syntheticExtensions/javaProperties/nonValidFirstChar.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("OnlyAscii.kt")
|
||||
public void testOnlyAscii() throws Exception {
|
||||
|
||||
+8
-1
@@ -65,8 +65,15 @@ fun getPropertyNamesCandidatesByAccessorName(name: Name): List<Name> {
|
||||
}
|
||||
|
||||
fun possibleGetMethodNames(propertyName: Name): List<Name> {
|
||||
val result = ArrayList<Name>(3)
|
||||
if (propertyName.isSpecial) return emptyList()
|
||||
|
||||
val identifier = propertyName.identifier
|
||||
if (identifier.isEmpty()) return emptyList()
|
||||
|
||||
val firstChar = identifier[0]
|
||||
if (!firstChar.isJavaIdentifierStart() || firstChar in 'A'..'Z') return emptyList()
|
||||
|
||||
val result = ArrayList<Name>(3)
|
||||
|
||||
if (JvmAbi.startsWithIsPrefix(identifier)) {
|
||||
result.add(propertyName)
|
||||
|
||||
Reference in New Issue
Block a user