diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticPropertiesScope.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticPropertiesScope.kt index 9a36e0c325e..ba73e435f49 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticPropertiesScope.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticPropertiesScope.kt @@ -24,6 +24,7 @@ import org.jetbrains.kotlin.descriptors.impl.PropertyGetterDescriptorImpl import org.jetbrains.kotlin.descriptors.impl.PropertySetterDescriptorImpl import org.jetbrains.kotlin.incremental.components.LookupLocation import org.jetbrains.kotlin.incremental.components.NoLookupLocation +import org.jetbrains.kotlin.load.java.JvmAbi import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter @@ -39,9 +40,7 @@ import org.jetbrains.kotlin.util.capitalizeDecapitalize.capitalizeFirstWord import org.jetbrains.kotlin.util.capitalizeDecapitalize.decapitalizeSmart import org.jetbrains.kotlin.utils.Printer import org.jetbrains.kotlin.utils.addIfNotNull -import java.util.ArrayList -import java.util.HashMap -import java.util.HashSet +import java.util.* import kotlin.properties.Delegates interface SyntheticJavaPropertyDescriptor : PropertyDescriptor { @@ -73,6 +72,8 @@ interface SyntheticJavaPropertyDescriptor : PropertyDescriptor { if (methodName.isSpecial()) return null val identifier = methodName.getIdentifier() if (!identifier.startsWith(prefix)) return null + if (identifier.length() == prefix.length()) return null + if (identifier[prefix.length()] in 'a'..'z') return null if (addPrefix != null) { assert(removePrefix) @@ -218,7 +219,7 @@ class JavaSyntheticPropertiesScope(storageManager: StorageManager) : JetScopeImp val result = ArrayList(3) val identifier = propertyName.identifier - if (identifier.startsWith("is")) { + if (JvmAbi.startsWithIsPrefix(identifier)) { result.add(propertyName) } diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/javaProperties/IsNaming.kt b/compiler/testData/diagnostics/tests/syntheticExtensions/javaProperties/IsNaming.kt index 45eb42ecf0a..b2a33047788 100644 --- a/compiler/testData/diagnostics/tests/syntheticExtensions/javaProperties/IsNaming.kt +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/javaProperties/IsNaming.kt @@ -6,6 +6,9 @@ fun foo(javaClass: JavaClass) { javaClass.something javaClass.isSomethingWrong javaClass.somethingWrong + + javaClass.issueFlag + javaClass.isSueFlag } // FILE: JavaClass.java @@ -27,4 +30,8 @@ public class JavaClass { public int isSomethingWrong() { return 1; } + + public boolean issueFlag() { + return true; + } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/javaProperties/IsNaming.txt b/compiler/testData/diagnostics/tests/syntheticExtensions/javaProperties/IsNaming.txt index 5f7f48d1f27..c3e7277144c 100644 --- a/compiler/testData/diagnostics/tests/syntheticExtensions/javaProperties/IsNaming.txt +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/javaProperties/IsNaming.txt @@ -9,6 +9,7 @@ public open class JavaClass { public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open fun isSomething(): kotlin.Boolean public open fun isSomethingWrong(): kotlin.Int + public open fun issueFlag(): kotlin.Boolean public open fun setIsSomething2(/*0*/ value: kotlin.Boolean): kotlin.Unit public open fun setSomething(/*0*/ value: kotlin.Boolean): kotlin.Unit public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/JvmAbi.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/JvmAbi.java index 623cad06a3a..ef0cb96d2c8 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/JvmAbi.java +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/JvmAbi.java @@ -90,7 +90,7 @@ public final class JvmAbi { : SET_PREFIX + CapitalizeDecapitalizeKt.capitalizeAsciiOnly(propertyName); } - private static boolean startsWithIsPrefix(String name) { + public static boolean startsWithIsPrefix(String name) { if (!name.startsWith(IS_PREFIX)) return false; if (name.length() == IS_PREFIX.length()) return false; char c = name.charAt(IS_PREFIX.length()); diff --git a/j2k/testData/fileOrElement/detectProperties/FalseGetter.java b/j2k/testData/fileOrElement/detectProperties/FalseGetter.java index 5b6024908b9..54721a8d6b2 100644 --- a/j2k/testData/fileOrElement/detectProperties/FalseGetter.java +++ b/j2k/testData/fileOrElement/detectProperties/FalseGetter.java @@ -5,4 +5,6 @@ public class AAA { public int getX() { return other.x; } + + public boolean issue() { return true; } } diff --git a/j2k/testData/fileOrElement/detectProperties/FalseGetter.kt b/j2k/testData/fileOrElement/detectProperties/FalseGetter.kt index 3d247c84c34..3ed4c9937d6 100644 --- a/j2k/testData/fileOrElement/detectProperties/FalseGetter.kt +++ b/j2k/testData/fileOrElement/detectProperties/FalseGetter.kt @@ -5,4 +5,8 @@ class AAA { fun getX(): Int { return other.x } + + fun issue(): Boolean { + return true + } }