diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticExtensionsScope.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticExtensionsScope.kt index 913ea8b4a4a..91cc5e7d961 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticExtensionsScope.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticExtensionsScope.kt @@ -104,14 +104,11 @@ class JavaSyntheticExtensionsScope(storageManager: StorageManager) : JetScope by val memberScope = ownerClass.unsubstitutedMemberScope val getMethod = possibleGetMethodNames(name) - .asSequence() .flatMap { memberScope.getFunctions(it).asSequence() } .singleOrNull { isGoodGetMethod(it) && it.hasJavaOriginInHierarchy() } ?: return null - // don't accept "uRL" for "getURL" etc - if (SyntheticJavaPropertyDescriptor.propertyNameByGetMethodName(getMethod.name) != name) return null val setMethod = memberScope.getFunctions(setMethodName(getMethod.name)) .singleOrNull { isGoodSetMethod(it, getMethod) } @@ -140,7 +137,7 @@ class JavaSyntheticExtensionsScope(storageManager: StorageManager) : JetScope by private fun isGoodSetMethod(descriptor: FunctionDescriptor, getMethod: FunctionDescriptor): Boolean { val propertyType = getMethod.returnType ?: return false val parameter = descriptor.valueParameters.singleOrNull() ?: return false - if (parameter.type != propertyType) { + if (!TypeUtils.equalTypes(parameter.type, propertyType)) { if (!propertyType.isSubtypeOf(parameter.type)) return false if (descriptor.findOverridden { val baseProperty = SyntheticJavaPropertyDescriptor.findByGetterOrSetter(it, this) @@ -225,7 +222,7 @@ class JavaSyntheticExtensionsScope(storageManager: StorageManager) : JetScope by //TODO: reuse code with generation? - private fun possibleGetMethodNames(propertyName: Name): Collection { + private fun possibleGetMethodNames(propertyName: Name): Sequence { val result = ArrayList(3) val identifier = propertyName.identifier @@ -239,7 +236,9 @@ class JavaSyntheticExtensionsScope(storageManager: StorageManager) : JetScope by if (capitalize2 != capitalize1) { result.add(Name.identifier("get" + capitalize2)) } - return result + + return result.asSequence() + .filter { SyntheticJavaPropertyDescriptor.propertyNameByGetMethodName(it) == propertyName } // don't accept "uRL" for "getURL" etc } private fun setMethodName(getMethodName: Name): Name { diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava3.kt b/compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava3.kt index 7af74313db4..568078acfd3 100644 --- a/compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava3.kt +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava3.kt @@ -9,7 +9,7 @@ fun foo(k: KotlinClass) { if (k.something == null) return k.setSomething("") - k.something = "" + k.something = "" } fun useString(i: String) {} diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/SyntheticPropertyAccessorReference.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/SyntheticPropertyAccessorReference.kt index 8faea2f7412..da13e967668 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/SyntheticPropertyAccessorReference.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/SyntheticPropertyAccessorReference.kt @@ -62,9 +62,9 @@ sealed class SyntheticPropertyAccessorReference(expression: JetNameReferenceExpr SyntheticJavaPropertyDescriptor.propertyNameByGetMethodName(newNameAsName) } else { - val propertyDescriptor = super.getTargetDescriptors(expression.analyze(BodyResolveMode.PARTIAL)) - .singleOrNull { it.original is SyntheticJavaPropertyDescriptor } ?: return expression - SyntheticJavaPropertyDescriptor.propertyNameBySetMethodName(newNameAsName, withIsPrefix = propertyDescriptor.getName().asString().startsWith("is")) + //TODO: it's not correct + //TODO: setIsY -> setIsIsY bug + SyntheticJavaPropertyDescriptor.propertyNameBySetMethodName(newNameAsName, withIsPrefix = expression.getReferencedNameAsName().asString().startsWith("is")) } if (newName == null) return expression //TODO: handle the case when get/set becomes ordinary method