diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/ReplaceAddWithPlusAssignIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/ReplaceAddWithPlusAssignIntention.kt index 1406810e8a2..8013e420542 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/ReplaceAddWithPlusAssignIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/ReplaceAddWithPlusAssignIntention.kt @@ -18,12 +18,12 @@ package org.jetbrains.kotlin.idea.intentions import com.intellij.openapi.editor.Editor import org.jetbrains.kotlin.builtins.DefaultBuiltIns +import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.idea.caches.resolve.analyze import org.jetbrains.kotlin.psi.KtDotQualifiedExpression import org.jetbrains.kotlin.psi.KtPsiFactory import org.jetbrains.kotlin.psi.createExpressionByPattern import org.jetbrains.kotlin.resolve.BindingContextUtils -import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall import org.jetbrains.kotlin.resolve.calls.resolvedCallUtil.getExplicitReceiverValue import org.jetbrains.kotlin.resolve.descriptorUtil.isSubclassOf @@ -47,7 +47,8 @@ class ReplaceAddWithPlusAssignIntention : SelfTargetingOffsetIndependentIntentio } ?: return false val resolvedCall = element.getResolvedCall(context) ?: return false - val receiverClass = DescriptorUtils.getClassDescriptorForType(resolvedCall.getExplicitReceiverValue()?.type ?: return false) + val receiverType = resolvedCall.getExplicitReceiverValue()?.type ?: return false + val receiverClass = receiverType.constructor.declarationDescriptor as? ClassDescriptor ?: return false return receiverClass.isSubclassOf(DefaultBuiltIns.Instance.mutableCollection) } diff --git a/idea/testData/intentions/replaceAddWithPlusAssign/addGeneric.kt b/idea/testData/intentions/replaceAddWithPlusAssign/addGeneric.kt new file mode 100644 index 00000000000..6721d65231a --- /dev/null +++ b/idea/testData/intentions/replaceAddWithPlusAssign/addGeneric.kt @@ -0,0 +1,5 @@ +// IS_APPLICABLE: false + +fun > foo(col: C) { + col.add(0) +} \ 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 445d1315985..4505f096f4c 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java @@ -13615,6 +13615,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest { doTest(fileName); } + @TestMetadata("addGeneric.kt") + public void testAddGeneric() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/replaceAddWithPlusAssign/addGeneric.kt"); + doTest(fileName); + } + @TestMetadata("addToVar.kt") public void testAddToVar() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/replaceAddWithPlusAssign/addToVar.kt");