Simplify for: take into account local property mutability
This commit is contained in:
@@ -185,6 +185,7 @@ class SimplifyForIntention : SelfTargetingRangeIntention<KtForExpression>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val property = parentCall.parent as? KtProperty
|
val property = parentCall.parent as? KtProperty
|
||||||
|
if (property != null && property.isVar) return null
|
||||||
val resolvedCall = parentCall.getResolvedCall(context) ?: return null
|
val resolvedCall = parentCall.getResolvedCall(context) ?: return null
|
||||||
|
|
||||||
val descriptor = resolvedCall.resultingDescriptor
|
val descriptor = resolvedCall.resultingDescriptor
|
||||||
|
|||||||
+13
@@ -0,0 +1,13 @@
|
|||||||
|
// IS_APPLICABLE: false
|
||||||
|
// WITH_RUNTIME
|
||||||
|
|
||||||
|
data class XY(val x: String, val y: Int)
|
||||||
|
fun test(xys: Array<XY>) {
|
||||||
|
for (<caret>xy in xys) {
|
||||||
|
val x = xy.x
|
||||||
|
var y = xy.y
|
||||||
|
println(x + y)
|
||||||
|
y--
|
||||||
|
println(y)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6603,6 +6603,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("DataClassWithLocalPropertyModified.kt")
|
||||||
|
public void testDataClassWithLocalPropertyModified() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/iterationOverMap/DataClassWithLocalPropertyModified.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("EntriesCallIsMissing.kt")
|
@TestMetadata("EntriesCallIsMissing.kt")
|
||||||
public void testEntriesCallIsMissing() throws Exception {
|
public void testEntriesCallIsMissing() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/iterationOverMap/EntriesCallIsMissing.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/iterationOverMap/EntriesCallIsMissing.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user