diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/replaceWith/DeprecatedSymbolUsageFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/replaceWith/DeprecatedSymbolUsageFix.kt index 02a79999d70..554fbfe60c2 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/replaceWith/DeprecatedSymbolUsageFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/replaceWith/DeprecatedSymbolUsageFix.kt @@ -55,7 +55,12 @@ class DeprecatedSymbolUsageFix( } fun isImportToBeRemoved(import: KtImportDirective): Boolean { - return !import.isAllUnder && import.targetDescriptors().all { + if (import.isAllUnder) return false + + val targetDescriptors = import.targetDescriptors() + if (targetDescriptors.isEmpty()) return false + + return targetDescriptors.all { DeprecatedSymbolUsageFixBase.fetchReplaceWithPattern(it, import.project) != null } } diff --git a/idea/testData/inspections/cleanup/cleanup.kt b/idea/testData/inspections/cleanup/cleanup.kt index caa21c05618..d7200e391b5 100644 --- a/idea/testData/inspections/cleanup/cleanup.kt +++ b/idea/testData/inspections/cleanup/cleanup.kt @@ -2,6 +2,7 @@ import pack.oldFun1 import pack.oldFun2 // should not be removed for non-deprecated overload used import pack.oldFun3 import kotlin.reflect.KProperty +import some.unresolved.declaration // should not be removed class A private() diff --git a/idea/testData/inspections/cleanup/cleanup.kt.after b/idea/testData/inspections/cleanup/cleanup.kt.after index 378f5a40534..2bd0bc5cadc 100644 --- a/idea/testData/inspections/cleanup/cleanup.kt.after +++ b/idea/testData/inspections/cleanup/cleanup.kt.after @@ -1,6 +1,7 @@ import pack.bar import pack.oldFun2 // should not be removed for non-deprecated overload used import kotlin.reflect.KProperty +import some.unresolved.declaration // should not be removed class A private constructor()