"is" getter naming allowed for non-booleans too
This commit is contained in:
-2
@@ -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()
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ fun foo(javaClass: JavaClass) {
|
||||
javaClass.isSomething2 = !javaClass.isSomething2
|
||||
|
||||
javaClass.<!UNRESOLVED_REFERENCE!>something<!>
|
||||
javaClass.<!FUNCTION_CALL_EXPECTED!>isSomethingWrong<!>
|
||||
javaClass.isSomethingWrong
|
||||
javaClass.<!UNRESOLVED_REFERENCE!>somethingWrong<!>
|
||||
|
||||
javaClass.<!FUNCTION_CALL_EXPECTED!>issueFlag<!>
|
||||
|
||||
@@ -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
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ internal interface I {
|
||||
|
||||
val isSomething2: Boolean?
|
||||
|
||||
fun isSomething3(): Int
|
||||
val isSomething3: Int
|
||||
|
||||
var isSomething4: Boolean
|
||||
|
||||
|
||||
Reference in New Issue
Block a user