Data Outflow: Allow for-loop variables

#KT-19018 Fixed
This commit is contained in:
Alexey Sedunov
2017-11-08 16:55:35 +03:00
parent fc307da383
commit 1ceb751061
4 changed files with 20 additions and 3 deletions
@@ -113,9 +113,7 @@ private fun KtDeclaration.processVariableAccesses(
)
}
private fun KtParameter.canProcess(): Boolean {
return !(isLoopParameter || isVarArg)
}
private fun KtParameter.canProcess() = !isVarArg
abstract class Slicer(
protected val element: KtExpression,
+9
View File
@@ -0,0 +1,9 @@
// FLOW: OUT
fun f1(param: String) {}
fun f4(list: List<String>) {
for (<caret>s in list)
if (s.isNotEmpty())
f1(s)
}
+4
View File
@@ -0,0 +1,4 @@
6 for (<bold>s</bold> in list)
7 if (<bold>s</bold>.isNotEmpty())
8 f1(<bold>s</bold>)
3 fun f1(<bold>param: String</bold>) {}
@@ -378,6 +378,12 @@ public class SlicerTestGenerated extends AbstractSlicerTest {
doTest(fileName);
}
@TestMetadata("outflow/forVariable.kt")
public void testOutflow_ForVariable() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/outflow/forVariable.kt");
doTest(fileName);
}
@TestMetadata("outflow/funBodyExpression.kt")
public void testOutflow_FunBodyExpression() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/outflow/funBodyExpression.kt");