diff --git a/plugins/kotlin/base/code-insight/src/org/jetbrains/kotlin/idea/core/NotPropertiesService.kt b/plugins/kotlin/base/code-insight/src/org/jetbrains/kotlin/idea/core/NotPropertiesService.kt index c210b929eed2..7367f0e082ba 100644 --- a/plugins/kotlin/base/code-insight/src/org/jetbrains/kotlin/idea/core/NotPropertiesService.kt +++ b/plugins/kotlin/base/code-insight/src/org/jetbrains/kotlin/idea/core/NotPropertiesService.kt @@ -28,9 +28,6 @@ interface NotPropertiesService { for (byteBufferMethod in listOf("getChar", "getDouble", "getFloat", "getInt", "getLong", "getShort")) { add("java.nio.ByteBuffer.$byteBufferMethod") } - - add("java.util.AbstractCollection.isEmpty") // KTIJ-31157 - add("java.util.AbstractMap.isEmpty") // KTIJ-31157 } fun getNotProperties(element: PsiElement): Set { diff --git a/plugins/kotlin/code-insight/inspections-k2/src/org/jetbrains/kotlin/idea/k2/codeinsight/inspections/UsePropertyAccessSyntaxInspection.kt b/plugins/kotlin/code-insight/inspections-k2/src/org/jetbrains/kotlin/idea/k2/codeinsight/inspections/UsePropertyAccessSyntaxInspection.kt index 484545d27c20..b8c36ac24b9d 100644 --- a/plugins/kotlin/code-insight/inspections-k2/src/org/jetbrains/kotlin/idea/k2/codeinsight/inspections/UsePropertyAccessSyntaxInspection.kt +++ b/plugins/kotlin/code-insight/inspections-k2/src/org/jetbrains/kotlin/idea/k2/codeinsight/inspections/UsePropertyAccessSyntaxInspection.kt @@ -646,7 +646,10 @@ class UsePropertyAccessSyntaxInspection : LocalInspectionTool(), CleanupLocalIns ) KotlinBundle.message("use.of.setter.method.instead.of.property.access.syntax") else KotlinBundle.message("use.of.getter.method.instead.of.property.access.syntax") - val propertiesNotToReplace = NotPropertiesService.DEFAULT.map(::FqNameUnsafe).toMutableSet() + val propertiesNotToReplace = + (NotPropertiesService.DEFAULT.map(::FqNameUnsafe) + + FqNameUnsafe("java.util.AbstractCollection.isEmpty") // KTIJ-31157 + + FqNameUnsafe("java.util.AbstractMap.isEmpty")).toMutableSet() // KTIJ-31157 // Serialized setting @Suppress("MemberVisibilityCanBePrivate") @@ -692,7 +695,13 @@ class NotPropertiesServiceImpl(private val project: Project) : NotPropertiesServ override fun getNotProperties(element: PsiElement): Set { val profile = InspectionProjectProfileManager.getInstance(project).currentProfile val tool = profile.getUnwrappedTool(USE_PROPERTY_ACCESS_INSPECTION, element) - return (tool?.propertiesNotToReplace ?: NotPropertiesService.DEFAULT.map(::FqNameUnsafe)).toSet() + var propertiesNotToReplace = tool?.propertiesNotToReplace + if (propertiesNotToReplace == null) { + propertiesNotToReplace = NotPropertiesService.DEFAULT.map(::FqNameUnsafe).toMutableSet() + propertiesNotToReplace.add(FqNameUnsafe("java.util.AbstractCollection.isEmpty")) // KTIJ-31157 + propertiesNotToReplace.add(FqNameUnsafe("java.util.AbstractMap.isEmpty")) // KTIJ-31157 + } + return propertiesNotToReplace } companion object {