diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/intentions/OperatorToFunctionIntention.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/intentions/OperatorToFunctionIntention.kt index 980326475e4..4be59ffd54c 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/intentions/OperatorToFunctionIntention.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/intentions/OperatorToFunctionIntention.kt @@ -20,6 +20,8 @@ import com.intellij.openapi.editor.Editor import com.intellij.psi.PsiElement import org.jetbrains.kotlin.descriptors.FunctionDescriptor import org.jetbrains.kotlin.idea.caches.resolve.analyze +import org.jetbrains.kotlin.idea.references.ReferenceAccess +import org.jetbrains.kotlin.idea.references.readWriteAccess import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.getQualifiedElementSelector @@ -61,6 +63,10 @@ public class OperatorToFunctionIntention : JetSelfTargetingIntention[""] += 10 +} \ No newline at end of file diff --git a/idea/testData/intentions/operatorToFunction/compoundAssignment2.kt b/idea/testData/intentions/operatorToFunction/compoundAssignment2.kt new file mode 100644 index 00000000000..d59d720291a --- /dev/null +++ b/idea/testData/intentions/operatorToFunction/compoundAssignment2.kt @@ -0,0 +1,8 @@ +// WITH_RUNTIME +interface C { + operator fun get(p: String): MutableList +} + +fun foo(c: C) { + c[""] += 10 +} \ No newline at end of file diff --git a/idea/testData/intentions/operatorToFunction/compoundAssignment2.kt.after b/idea/testData/intentions/operatorToFunction/compoundAssignment2.kt.after new file mode 100644 index 00000000000..170f13a07ba --- /dev/null +++ b/idea/testData/intentions/operatorToFunction/compoundAssignment2.kt.after @@ -0,0 +1,8 @@ +// WITH_RUNTIME +interface C { + operator fun get(p: String): MutableList +} + +fun foo(c: C) { + c.get("") += 10 +} \ No newline at end of file diff --git a/idea/testData/intentions/operatorToFunction/pluPlus.kt b/idea/testData/intentions/operatorToFunction/pluPlus.kt new file mode 100644 index 00000000000..ea420e05011 --- /dev/null +++ b/idea/testData/intentions/operatorToFunction/pluPlus.kt @@ -0,0 +1,9 @@ +// IS_APPLICABLE: false +interface C { + operator fun get(p: String): Int + operator fun set(p: String, value: Int) +} + +fun foo(c: C) { + c[""]++ +} \ 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 d8f395db3bb..0b34a66d13a 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java @@ -5901,6 +5901,18 @@ public class IntentionTestGenerated extends AbstractIntentionTest { doTest(fileName); } + @TestMetadata("compoundAssignment.kt") + public void testCompoundAssignment() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/operatorToFunction/compoundAssignment.kt"); + doTest(fileName); + } + + @TestMetadata("compoundAssignment2.kt") + public void testCompoundAssignment2() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/operatorToFunction/compoundAssignment2.kt"); + doTest(fileName); + } + @TestMetadata("functionCallMultipleArgument.kt") public void testFunctionCallMultipleArgument() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/operatorToFunction/functionCallMultipleArgument.kt"); @@ -5949,6 +5961,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest { doTest(fileName); } + @TestMetadata("pluPlus.kt") + public void testPluPlus() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/operatorToFunction/pluPlus.kt"); + doTest(fileName); + } + @TestMetadata("postfixMinusMinus.kt") public void testPostfixMinusMinus() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/operatorToFunction/postfixMinusMinus.kt");