Skip to content

Commit 20bddce

Browse files
committed
No synthetic property for false get-method like "issue()"
1 parent 8f1a304 commit 20bddce

File tree

6 files changed

+20
-5
lines changed

6 files changed

+20
-5
lines changed

compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticPropertiesScope.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.descriptors.impl.PropertyGetterDescriptorImpl
2424
import org.jetbrains.kotlin.descriptors.impl.PropertySetterDescriptorImpl
2525
import org.jetbrains.kotlin.incremental.components.LookupLocation
2626
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
27+
import org.jetbrains.kotlin.load.java.JvmAbi
2728
import org.jetbrains.kotlin.name.Name
2829
import org.jetbrains.kotlin.resolve.DescriptorUtils
2930
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
@@ -39,9 +40,7 @@ import org.jetbrains.kotlin.util.capitalizeDecapitalize.capitalizeFirstWord
3940
import org.jetbrains.kotlin.util.capitalizeDecapitalize.decapitalizeSmart
4041
import org.jetbrains.kotlin.utils.Printer
4142
import org.jetbrains.kotlin.utils.addIfNotNull
42-
import java.util.ArrayList
43-
import java.util.HashMap
44-
import java.util.HashSet
43+
import java.util.*
4544
import kotlin.properties.Delegates
4645

4746
interface SyntheticJavaPropertyDescriptor : PropertyDescriptor {
@@ -73,6 +72,8 @@ interface SyntheticJavaPropertyDescriptor : PropertyDescriptor {
7372
if (methodName.isSpecial()) return null
7473
val identifier = methodName.getIdentifier()
7574
if (!identifier.startsWith(prefix)) return null
75+
if (identifier.length() == prefix.length()) return null
76+
if (identifier[prefix.length()] in 'a'..'z') return null
7677

7778
if (addPrefix != null) {
7879
assert(removePrefix)
@@ -218,7 +219,7 @@ class JavaSyntheticPropertiesScope(storageManager: StorageManager) : JetScopeImp
218219
val result = ArrayList<Name>(3)
219220
val identifier = propertyName.identifier
220221

221-
if (identifier.startsWith("is")) {
222+
if (JvmAbi.startsWithIsPrefix(identifier)) {
222223
result.add(propertyName)
223224
}
224225

compiler/testData/diagnostics/tests/syntheticExtensions/javaProperties/IsNaming.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ fun foo(javaClass: JavaClass) {
66
javaClass.<!UNRESOLVED_REFERENCE!>something<!>
77
javaClass.<!FUNCTION_CALL_EXPECTED!>isSomethingWrong<!>
88
javaClass.<!UNRESOLVED_REFERENCE!>somethingWrong<!>
9+
10+
javaClass.<!FUNCTION_CALL_EXPECTED!>issueFlag<!>
11+
javaClass.<!UNRESOLVED_REFERENCE!>isSueFlag<!>
912
}
1013

1114
// FILE: JavaClass.java
@@ -27,4 +30,8 @@ public class JavaClass {
2730
public int isSomethingWrong() {
2831
return 1;
2932
}
33+
34+
public boolean issueFlag() {
35+
return true;
36+
}
3037
}

compiler/testData/diagnostics/tests/syntheticExtensions/javaProperties/IsNaming.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ public open class JavaClass {
99
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
1010
public open fun isSomething(): kotlin.Boolean
1111
public open fun isSomethingWrong(): kotlin.Int
12+
public open fun issueFlag(): kotlin.Boolean
1213
public open fun setIsSomething2(/*0*/ value: kotlin.Boolean): kotlin.Unit
1314
public open fun setSomething(/*0*/ value: kotlin.Boolean): kotlin.Unit
1415
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String

core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/JvmAbi.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public static String setterName(@NotNull String propertyName) {
9090
: SET_PREFIX + CapitalizeDecapitalizeKt.capitalizeAsciiOnly(propertyName);
9191
}
9292

93-
private static boolean startsWithIsPrefix(String name) {
93+
public static boolean startsWithIsPrefix(String name) {
9494
if (!name.startsWith(IS_PREFIX)) return false;
9595
if (name.length() == IS_PREFIX.length()) return false;
9696
char c = name.charAt(IS_PREFIX.length());

j2k/testData/fileOrElement/detectProperties/FalseGetter.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@ public class AAA {
55
public int getX() {
66
return other.x;
77
}
8+
9+
public boolean issue() { return true; }
810
}

j2k/testData/fileOrElement/detectProperties/FalseGetter.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,8 @@ class AAA {
55
fun getX(): Int {
66
return other.x
77
}
8+
9+
fun issue(): Boolean {
10+
return true
11+
}
812
}

0 commit comments

Comments
 (0)