From b0d294b50c0ee1bfc6fe4b4a8c3749a9146cce10 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Tue, 7 May 2019 19:08:12 +0300 Subject: [PATCH] Use candidate descriptor to determine parameter name stability in IDEA #KT-31349 Fixed --- .../idea/inspections/BooleanLiteralArgumentInspection.kt | 2 +- .../kotlin/idea/intentions/AddNameToArgumentIntention.kt | 2 +- .../idea/intentions/AddNamesToCallArgumentsIntention.kt | 2 +- idea/testData/intentions/addNameToArgument/linkedList.kt | 8 ++++++++ .../kotlin/idea/intentions/IntentionTestGenerated.java | 5 +++++ 5 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 idea/testData/intentions/addNameToArgument/linkedList.kt diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/BooleanLiteralArgumentInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/BooleanLiteralArgumentInspection.kt index e2b4a164af7..0abe16f4536 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/BooleanLiteralArgumentInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/BooleanLiteralArgumentInspection.kt @@ -43,7 +43,7 @@ class BooleanLiteralArgumentInspection( if (AddNameToArgumentIntention.detectNameToAdd(argument, shouldBeLastUnnamed = false) == null) return val resolvedCall = call.resolveToCall() ?: return - if (!resolvedCall.resultingDescriptor.hasStableParameterNames()) return + if (!resolvedCall.candidateDescriptor.hasStableParameterNames()) return val languageVersionSettings = call.languageVersionSettings if (valueArguments.any { !AddNameToArgumentIntention.argumentMatchedAndCouldBeNamedInCall(it, resolvedCall, languageVersionSettings) diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/AddNameToArgumentIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/AddNameToArgumentIntention.kt index 8c9b2a66f39..8d78bcf5648 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/AddNameToArgumentIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/AddNameToArgumentIntention.kt @@ -77,7 +77,7 @@ class AddNameToArgumentIntention : SelfTargetingIntention( val callExpr = argumentList.parent as? KtCallElement ?: return null val resolvedCall = givenResolvedCall ?: callExpr.resolveToCall() ?: return null - if (!resolvedCall.resultingDescriptor.hasStableParameterNames()) return null + if (!resolvedCall.candidateDescriptor.hasStableParameterNames()) return null if (!argumentMatchedAndCouldBeNamedInCall(argument, resolvedCall, callExpr.languageVersionSettings)) return null diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/AddNamesToCallArgumentsIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/AddNamesToCallArgumentsIntention.kt index 1cbd4bddb37..50559c6b67b 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/AddNamesToCallArgumentsIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/AddNamesToCallArgumentsIntention.kt @@ -33,7 +33,7 @@ class AddNamesToCallArgumentsIntention : SelfTargetingRangeIntention(listOf(1, 2)) +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java index d03dc2e7d96..5a493d9919c 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java @@ -1211,6 +1211,11 @@ public class IntentionTestGenerated extends AbstractIntentionTest { runTest("idea/testData/intentions/addNameToArgument/kt11679.kt"); } + @TestMetadata("linkedList.kt") + public void testLinkedList() throws Exception { + runTest("idea/testData/intentions/addNameToArgument/linkedList.kt"); + } + @TestMetadata("notInsideIndices.kt") public void testNotInsideIndices() throws Exception { runTest("idea/testData/intentions/addNameToArgument/notInsideIndices.kt");