diff --git a/idea/testData/intentions/useWithIndex/indexIncrementTwice.kt b/idea/testData/intentions/useWithIndex/indexIncrementTwice.kt new file mode 100644 index 00000000000..7220d11278c --- /dev/null +++ b/idea/testData/intentions/useWithIndex/indexIncrementTwice.kt @@ -0,0 +1,11 @@ +// WITH_RUNTIME +// IS_APPLICABLE: false +fun foo(list: List): Int? { + var index = 0 + for (s in list) { + val x = s.length * index++ + index++ + if (x > 0) return x + } + return null +} \ No newline at end of file diff --git a/idea/testData/intentions/useWithIndex/indexUsedAfterLoop.kt b/idea/testData/intentions/useWithIndex/indexUsedAfterLoop.kt new file mode 100644 index 00000000000..7f05b421b75 --- /dev/null +++ b/idea/testData/intentions/useWithIndex/indexUsedAfterLoop.kt @@ -0,0 +1,11 @@ +// WITH_RUNTIME +// IS_APPLICABLE: false +fun foo(list: List): Int { + var index = 0 + for (s in list) { + val x = s.length * index++ + print(x) + print(s) + } + return index +} \ 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 434ee7cb7e8..a8ef162ce4f 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java @@ -11591,12 +11591,24 @@ public class IntentionTestGenerated extends AbstractIntentionTest { doTest(fileName); } + @TestMetadata("indexIncrementTwice.kt") + public void testIndexIncrementTwice() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/useWithIndex/indexIncrementTwice.kt"); + doTest(fileName); + } + @TestMetadata("indexPlusPlusInsideExpression.kt") public void testIndexPlusPlusInsideExpression() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/useWithIndex/indexPlusPlusInsideExpression.kt"); doTest(fileName); } + @TestMetadata("indexUsedAfterLoop.kt") + public void testIndexUsedAfterLoop() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/useWithIndex/indexUsedAfterLoop.kt"); + doTest(fileName); + } + @TestMetadata("prefixPlusPlusInsideExpression.kt") public void testPrefixPlusPlusInsideExpression() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/useWithIndex/prefixPlusPlusInsideExpression.kt");