Use candidate descriptor to determine parameter name stability in IDEA

#KT-31349 Fixed
This commit is contained in:
Mikhail Glukhikh
2019-05-07 19:08:12 +03:00
parent d517276a06
commit b0d294b50c
5 changed files with 16 additions and 3 deletions
@@ -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)
@@ -77,7 +77,7 @@ class AddNameToArgumentIntention : SelfTargetingIntention<KtValueArgument>(
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
@@ -33,7 +33,7 @@ class AddNamesToCallArgumentsIntention : SelfTargetingRangeIntention<KtCallEleme
if (arguments.all { it.isNamed() || it is LambdaArgument }) return null
val resolvedCall = element.resolveToCall() ?: return null
if (!resolvedCall.resultingDescriptor.hasStableParameterNames()) return null
if (!resolvedCall.candidateDescriptor.hasStableParameterNames()) return null
if (arguments.all {
AddNameToArgumentIntention.argumentMatchedAndCouldBeNamedInCall(it, resolvedCall, element.languageVersionSettings)
@@ -0,0 +1,8 @@
// IS_APPLICABLE: false
// RUNTIME_WITH_FULL_JDK
import java.util.*
fun test() {
LinkedList<Int>(<caret>listOf(1, 2))
}
@@ -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");