From 94d8e3f4b629ca89d2af0b90ce79b0c8d5d46a1f Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Mon, 28 Sep 2015 22:20:45 +0300 Subject: [PATCH] "is" getter naming allowed for non-booleans too --- .../kotlin/synthetic/JavaSyntheticPropertiesScope.kt | 2 -- .../tests/syntheticExtensions/javaProperties/IsNaming.kt | 2 +- j2k/src/org/jetbrains/kotlin/j2k/propertyDetection.kt | 5 ----- j2k/testData/fileOrElement/detectProperties/IsPrefix.kt | 2 +- 4 files changed, 2 insertions(+), 9 deletions(-) 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 ba73e435f49..0abe34cbc9f 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticPropertiesScope.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticPropertiesScope.kt @@ -32,7 +32,6 @@ import org.jetbrains.kotlin.resolve.scopes.JetScope import org.jetbrains.kotlin.resolve.scopes.JetScopeImpl import org.jetbrains.kotlin.storage.StorageManager import org.jetbrains.kotlin.types.* -import org.jetbrains.kotlin.types.typeUtil.isBoolean import org.jetbrains.kotlin.types.typeUtil.isSubtypeOf import org.jetbrains.kotlin.types.typeUtil.isUnit import org.jetbrains.kotlin.util.capitalizeDecapitalize.capitalizeAsciiOnly @@ -118,7 +117,6 @@ class JavaSyntheticPropertiesScope(storageManager: StorageManager) : JetScopeImp private fun isGoodGetMethod(descriptor: FunctionDescriptor): Boolean { val returnType = descriptor.returnType ?: return false if (returnType.isUnit()) return false - if (descriptor.name.asString().startsWith("is") && !returnType.isBoolean()) return false return descriptor.valueParameters.isEmpty() && descriptor.typeParameters.isEmpty() diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/javaProperties/IsNaming.kt b/compiler/testData/diagnostics/tests/syntheticExtensions/javaProperties/IsNaming.kt index b2a33047788..eaa03f7c860 100644 --- a/compiler/testData/diagnostics/tests/syntheticExtensions/javaProperties/IsNaming.kt +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/javaProperties/IsNaming.kt @@ -4,7 +4,7 @@ fun foo(javaClass: JavaClass) { javaClass.isSomething2 = !javaClass.isSomething2 javaClass.something - javaClass.isSomethingWrong + javaClass.isSomethingWrong javaClass.somethingWrong javaClass.issueFlag diff --git a/j2k/src/org/jetbrains/kotlin/j2k/propertyDetection.kt b/j2k/src/org/jetbrains/kotlin/j2k/propertyDetection.kt index eaeff2bf4bf..77316d45ad2 100644 --- a/j2k/src/org/jetbrains/kotlin/j2k/propertyDetection.kt +++ b/j2k/src/org/jetbrains/kotlin/j2k/propertyDetection.kt @@ -385,11 +385,6 @@ private class PropertyDetector( if (!Name.isValidIdentifier(name)) return null val propertyName = SyntheticJavaPropertyDescriptor.propertyNameByGetMethodName(Name.identifier(name))?.identifier ?: return null - if (name.startsWith("is")) { - val typeText = method.returnType?.canonicalText - if (typeText != "boolean" && typeText != "java.lang.Boolean") return null - } - val returnType = method.returnType ?: return null if (returnType.canonicalText == "void") return null if (method.typeParameters.isNotEmpty()) return null diff --git a/j2k/testData/fileOrElement/detectProperties/IsPrefix.kt b/j2k/testData/fileOrElement/detectProperties/IsPrefix.kt index b4d76b6cbd5..8e0f130ade3 100644 --- a/j2k/testData/fileOrElement/detectProperties/IsPrefix.kt +++ b/j2k/testData/fileOrElement/detectProperties/IsPrefix.kt @@ -6,7 +6,7 @@ internal interface I { val isSomething2: Boolean? - fun isSomething3(): Int + val isSomething3: Int var isSomething4: Boolean