diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt index 40689ed3d92..2ae729be32d 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt @@ -52,6 +52,10 @@ class SyntheticExtensionsScope(storageManager: StorageManager) : JetScope by Jet } private fun syntheticPropertyInClassNotCached(javaClass: JavaClassDescriptor, type: JetType, name: Name): PropertyDescriptor? { + if (name.isSpecial()) return null + val firstChar = name.getIdentifier()[0] + if (!firstChar.isJavaIdentifierStart() || firstChar.isUpperCase()) return null + val memberScope = javaClass.getMemberScope(type.getArguments()) val getMethod = memberScope.getFunctions(toGetMethodName(name)).singleOrNull { isGoodGetMethod(it) } ?: return null @@ -75,8 +79,6 @@ class SyntheticExtensionsScope(storageManager: StorageManager) : JetScope by Jet } override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name): Collection { - if (name.isSpecial()) return emptyList() - if (name.getIdentifier()[0].isUpperCase()) return emptyList() return collectSyntheticPropertiesByName(null, receiverType.makeNotNullable(), name) ?: emptyList() } @@ -138,7 +140,9 @@ class SyntheticExtensionsScope(storageManager: StorageManager) : JetScope by Jet if (methodName.isSpecial()) return null val identifier = methodName.getIdentifier() if (!identifier.startsWith("get")) return null - return Name.identifier(identifier.removePrefix("get").decapitalize()) + val name = identifier.removePrefix("get").decapitalize() + if (!Name.isValidIdentifier(name)) return null + return Name.identifier(name) } private class MyPropertyDescriptor( diff --git a/idea/idea-completion/testData/basic/multifile/IncorrectGetters/IncorrectGetters.dependency.java b/idea/idea-completion/testData/basic/multifile/IncorrectGetters/IncorrectGetters.dependency.java new file mode 100644 index 00000000000..366ce6faf45 --- /dev/null +++ b/idea/idea-completion/testData/basic/multifile/IncorrectGetters/IncorrectGetters.dependency.java @@ -0,0 +1,4 @@ +class JavaClass { + public int get() { return 1; } + public int get1() { return 1; } +} \ No newline at end of file diff --git a/idea/idea-completion/testData/basic/multifile/IncorrectGetters/IncorrectGetters.kt b/idea/idea-completion/testData/basic/multifile/IncorrectGetters/IncorrectGetters.kt new file mode 100644 index 00000000000..1618af5451f --- /dev/null +++ b/idea/idea-completion/testData/basic/multifile/IncorrectGetters/IncorrectGetters.kt @@ -0,0 +1,6 @@ +fun foo(javaClass: JavaClass) { + javaClass. +} + +// ABSENT: "" +// ABSENT: "1" diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/MultiFileJvmBasicCompletionTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/MultiFileJvmBasicCompletionTestGenerated.java index 381132ceeab..dc47865b47f 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/MultiFileJvmBasicCompletionTestGenerated.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/MultiFileJvmBasicCompletionTestGenerated.java @@ -131,6 +131,12 @@ public class MultiFileJvmBasicCompletionTestGenerated extends AbstractMultiFileJ doTest(fileName); } + @TestMetadata("IncorrectGetters") + public void testIncorrectGetters() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/multifile/IncorrectGetters/"); + doTest(fileName); + } + @TestMetadata("JavaInnerClasses") public void testJavaInnerClasses() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/multifile/JavaInnerClasses/");