Unused symbol: don't suggest actual declaration used in another platform
Related to KT-17512 Related to KT-15666
This commit is contained in:
@@ -50,6 +50,7 @@ import org.jetbrains.kotlin.idea.imports.importableFqName
|
|||||||
import org.jetbrains.kotlin.idea.quickfix.RemoveUnusedFunctionParameterFix
|
import org.jetbrains.kotlin.idea.quickfix.RemoveUnusedFunctionParameterFix
|
||||||
import org.jetbrains.kotlin.idea.references.mainReference
|
import org.jetbrains.kotlin.idea.references.mainReference
|
||||||
import org.jetbrains.kotlin.idea.references.resolveMainReferenceToDescriptors
|
import org.jetbrains.kotlin.idea.references.resolveMainReferenceToDescriptors
|
||||||
|
import org.jetbrains.kotlin.idea.search.ideaExtensions.KotlinReferencesSearchOptions
|
||||||
import org.jetbrains.kotlin.idea.search.ideaExtensions.KotlinReferencesSearchParameters
|
import org.jetbrains.kotlin.idea.search.ideaExtensions.KotlinReferencesSearchParameters
|
||||||
import org.jetbrains.kotlin.idea.search.isCheapEnoughToSearchConsideringOperators
|
import org.jetbrains.kotlin.idea.search.isCheapEnoughToSearchConsideringOperators
|
||||||
import org.jetbrains.kotlin.idea.search.projectScope
|
import org.jetbrains.kotlin.idea.search.projectScope
|
||||||
@@ -281,7 +282,11 @@ class UnusedSymbolInspection : AbstractKotlinInspection() {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
val searchParameters = KotlinReferencesSearchParameters(declaration, useScope)
|
val searchParameters = KotlinReferencesSearchParameters(
|
||||||
|
declaration,
|
||||||
|
useScope,
|
||||||
|
kotlinOptions = KotlinReferencesSearchOptions(acceptCallableOverrides = declaration.hasActualModifier())
|
||||||
|
)
|
||||||
val referenceUsed: Boolean by lazy { !ReferencesSearch.search(searchParameters).forEach(::checkReference) }
|
val referenceUsed: Boolean by lazy { !ReferencesSearch.search(searchParameters).forEach(::checkReference) }
|
||||||
|
|
||||||
if (descriptor is FunctionDescriptor &&
|
if (descriptor is FunctionDescriptor &&
|
||||||
|
|||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
expect class My constructor() {
|
||||||
|
fun foo()
|
||||||
|
}
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
expect class My constructor() {
|
||||||
|
fun foo()
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
actual class My {
|
||||||
|
actual fun foo() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
My().foo()
|
||||||
|
}
|
||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
actual class My {
|
||||||
|
actual fun foo() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
My().foo()
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// "Safe delete 'foo'" "false"
|
||||||
|
// TOOL: org.jetbrains.kotlin.idea.inspections.UnusedSymbolInspection
|
||||||
|
// ACTION: Convert member to extension
|
||||||
|
// ACTION: Move to companion object
|
||||||
|
|
||||||
|
actual class My {
|
||||||
|
actual fun <caret>foo() {}
|
||||||
|
}
|
||||||
+8
@@ -0,0 +1,8 @@
|
|||||||
|
// "Safe delete 'foo'" "false"
|
||||||
|
// TOOL: org.jetbrains.kotlin.idea.inspections.UnusedSymbolInspection
|
||||||
|
// ACTION: Convert member to extension
|
||||||
|
// ACTION: Move to companion object
|
||||||
|
|
||||||
|
actual class My {
|
||||||
|
actual fun foo() {}
|
||||||
|
}
|
||||||
+5
@@ -344,6 +344,11 @@ public class QuickFixMultiModuleTestGenerated extends AbstractQuickFixMultiModul
|
|||||||
runTest("idea/testData/multiModuleQuickFix/safeDeleteFromActual/");
|
runTest("idea/testData/multiModuleQuickFix/safeDeleteFromActual/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("safeDeleteUsedInAnotherPlatform")
|
||||||
|
public void testSafeDeleteUsedInAnotherPlatform() throws Exception {
|
||||||
|
runTest("idea/testData/multiModuleQuickFix/safeDeleteUsedInAnotherPlatform/");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("sealed")
|
@TestMetadata("sealed")
|
||||||
public void testSealed() throws Exception {
|
public void testSealed() throws Exception {
|
||||||
runTest("idea/testData/multiModuleQuickFix/sealed/");
|
runTest("idea/testData/multiModuleQuickFix/sealed/");
|
||||||
|
|||||||
Reference in New Issue
Block a user