KT-9450 «Replace overloaded operator with function call» breaks code for index access result saved to variable
#KT-9450 Fixed
This commit is contained in:
+1
-1
@@ -168,7 +168,7 @@ public class OperatorToFunctionIntention : JetSelfTargetingIntention<KtExpressio
|
||||
|
||||
val transformation : String
|
||||
val replaced : KtElement
|
||||
if (parent is KtBinaryExpression && parent.getOperationReference().getReferencedNameElementType() == KtTokens.EQ) {
|
||||
if (parent is KtBinaryExpression && parent.getOperationReference().getReferencedNameElementType() == KtTokens.EQ && element == parent.left) {
|
||||
// part of an assignment
|
||||
val right = parent.getRight()!!.getText()
|
||||
transformation = "$array.set($indicesText, $right)"
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
fun foo(map: Map<String, String>) {
|
||||
val a: String?
|
||||
a = map<caret>[""]
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
fun foo(map: Map<String, String>) {
|
||||
val a: String?
|
||||
a = map.get("")
|
||||
}
|
||||
@@ -5919,6 +5919,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("inRightSideOfAssignment.kt")
|
||||
public void testInRightSideOfAssignment() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/operatorToFunction/inRightSideOfAssignment.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("notApplicableAssignment.kt")
|
||||
public void testNotApplicableAssignment() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/operatorToFunction/notApplicableAssignment.kt");
|
||||
|
||||
Reference in New Issue
Block a user