Unused symbol: don't suggest actual declaration used in another platform

Related to KT-17512
Related to KT-15666
This commit is contained in:
Mikhail Glukhikh
2018-06-26 15:34:12 +03:00
parent 30327aa9cc
commit eb92b7ed7f
8 changed files with 47 additions and 1 deletions
@@ -50,6 +50,7 @@ import org.jetbrains.kotlin.idea.imports.importableFqName
import org.jetbrains.kotlin.idea.quickfix.RemoveUnusedFunctionParameterFix
import org.jetbrains.kotlin.idea.references.mainReference
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.isCheapEnoughToSearchConsideringOperators
import org.jetbrains.kotlin.idea.search.projectScope
@@ -281,7 +282,11 @@ class UnusedSymbolInspection : AbstractKotlinInspection() {
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) }
if (descriptor is FunctionDescriptor &&
@@ -0,0 +1,3 @@
expect class My constructor() {
fun foo()
}
@@ -0,0 +1,3 @@
expect class My constructor() {
fun foo()
}
@@ -0,0 +1,7 @@
actual class My {
actual fun foo() {}
}
fun test() {
My().foo()
}
@@ -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() {}
}
@@ -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() {}
}
@@ -344,6 +344,11 @@ public class QuickFixMultiModuleTestGenerated extends AbstractQuickFixMultiModul
runTest("idea/testData/multiModuleQuickFix/safeDeleteFromActual/");
}
@TestMetadata("safeDeleteUsedInAnotherPlatform")
public void testSafeDeleteUsedInAnotherPlatform() throws Exception {
runTest("idea/testData/multiModuleQuickFix/safeDeleteUsedInAnotherPlatform/");
}
@TestMetadata("sealed")
public void testSealed() throws Exception {
runTest("idea/testData/multiModuleQuickFix/sealed/");