mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
KTIJ-31590 K2: don't warn about unused parameters for external functions
GitOrigin-RevId: 3b010e9f20478f6d4b0d0fc60579ea91b42d300e
This commit is contained in:
committed by
intellij-monorepo-bot
parent
0bfb7b64c3
commit
cfa1938d3d
+5
@@ -307,6 +307,11 @@ public abstract class K2UnusedSymbolHighlightingTestGenerated extends AbstractK2
|
||||
runTest("../../../idea/tests/testData/inspectionsLocal/unusedSymbol/expectFunctionParameter.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("externalFunWithUnusedParameter.kt")
|
||||
public void testExternalFunWithUnusedParameter() throws Exception {
|
||||
runTest("../../../idea/tests/testData/inspectionsLocal/unusedSymbol/externalFunWithUnusedParameter.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("functionCall.kt")
|
||||
public void testFunctionCall() throws Exception {
|
||||
runTest("../../../idea/tests/testData/inspectionsLocal/unusedSymbol/functionCall.kt");
|
||||
|
||||
+4
-1
@@ -130,6 +130,9 @@ object K2UnusedSymbolUtil {
|
||||
context(KaSession)
|
||||
@OptIn(KaExperimentalApi::class)
|
||||
fun getPsiToReportProblem(declaration: KtNamedDeclaration, isJavaEntryPointInspection: UnusedDeclarationInspectionBase): PsiElement? {
|
||||
if (((declaration as? KtParameter)?.parent?.parent as? KtModifierListOwner)?.hasModifier(KtTokens.EXTERNAL_KEYWORD) == true) {
|
||||
return null
|
||||
}
|
||||
val symbol = declaration.symbol
|
||||
if (declaration.languageVersionSettings.getFlag(
|
||||
AnalysisFlags.explicitApiMode) != ExplicitApiMode.DISABLED && symbol.compilerVisibility.isPublicAPI) {
|
||||
@@ -647,7 +650,7 @@ object K2UnusedSymbolUtil {
|
||||
return when {
|
||||
symbol is KaConstructorSymbol -> {
|
||||
val classSymbol = symbol.containingDeclaration as? KaNamedClassSymbol ?: return false
|
||||
!classSymbol.isInline && !(classSymbol.visibility == KaSymbolVisibility.PRIVATE)
|
||||
!classSymbol.isInline && classSymbol.visibility != KaSymbolVisibility.PRIVATE
|
||||
}
|
||||
hasModifier(KtTokens.INTERNAL_KEYWORD) -> false
|
||||
symbol !is KaNamedFunctionSymbol -> true
|
||||
|
||||
+4
-3
@@ -161,9 +161,10 @@ class KotlinUnusedHighlightingVisitor(private val ktFile: KtFile) {
|
||||
holder: HighlightInfoHolder) {
|
||||
if (!K2UnusedSymbolUtil.isApplicableByPsi(declaration)) return
|
||||
if (refHolder.isUsedLocally(declaration)) return // even for non-private declarations our refHolder might have usage info
|
||||
val mustBeLocallyReferenced = declaration is KtParameter && !(declaration.hasValOrVar()) ||
|
||||
declaration.hasModifier(KtTokens.PRIVATE_KEYWORD) ||
|
||||
((declaration.parent as? KtClassBody)?.parent as? KtClassOrObject)?.isLocal == true
|
||||
val mustBeLocallyReferenced = declaration is KtParameter && !declaration.hasValOrVar()
|
||||
&& (declaration.parent?.parent as? KtModifierListOwner)?.hasModifier(KtTokens.EXTERNAL_KEYWORD) != true // parameters of external functions might be referenced elsewhere
|
||||
|| declaration.hasModifier(KtTokens.PRIVATE_KEYWORD)
|
||||
|| ((declaration.parent as? KtClassBody)?.parent as? KtClassOrObject)?.isLocal == true
|
||||
if (SuppressionUtil.inspectionResultSuppressed(declaration, deadCodeInspection)) {
|
||||
return
|
||||
}
|
||||
|
||||
+5
@@ -18173,6 +18173,11 @@ public abstract class LocalInspectionTestGenerated extends AbstractLocalInspecti
|
||||
runTest("testData/inspectionsLocal/unusedSymbol/expectFunctionParameter.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("externalFunWithUnusedParameter.kt")
|
||||
public void testExternalFunWithUnusedParameter() throws Exception {
|
||||
runTest("testData/inspectionsLocal/unusedSymbol/externalFunWithUnusedParameter.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("functionCall.kt")
|
||||
public void testFunctionCall() throws Exception {
|
||||
runTest("testData/inspectionsLocal/unusedSymbol/functionCall.kt");
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
// PROBLEM: none
|
||||
class M {
|
||||
private external fun sdkfjlsdkjf(<caret>sdfsd: Int):Int
|
||||
override fun hashCode() = sdkfjlsdkjf(0)
|
||||
}
|
||||
Reference in New Issue
Block a user