diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/java/ControlFlowAnalyzer.java b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/java/ControlFlowAnalyzer.java index 02b3258e8933..fd6094c6572b 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/java/ControlFlowAnalyzer.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/java/ControlFlowAnalyzer.java @@ -1841,10 +1841,7 @@ public class ControlFlowAnalyzer extends JavaElementVisitor { if (val instanceof Integer) { int lengthValue = (Integer)val; if (lengthValue > 0 && lengthValue <= MAX_UNROLL_SIZE) { - DfaVariableValue var = getTargetVariable(arrayExpression); - if (var == null) { - var = createTempVariable(type); - } + DfaVariableValue var = createTempVariable(type); addInstruction(new PushInstruction(var, null, true)); addInstruction(new SwapInstruction()); addInstruction(new AssignInstruction(null, var)); diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/InitArrayInConstructor.java b/java/java-tests/testData/inspection/dataFlow/fixture/InitArrayInConstructor.java new file mode 100644 index 000000000000..24fc2c0ff2b5 --- /dev/null +++ b/java/java-tests/testData/inspection/dataFlow/fixture/InitArrayInConstructor.java @@ -0,0 +1,7 @@ +public class InitArrayInConstructor { + double[] arr; + + InitArrayInConstructor() { + arr = new double[3]; + } +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/java/codeInspection/DataFlowInspectionTest.java b/java/java-tests/testSrc/com/intellij/java/codeInspection/DataFlowInspectionTest.java index bacea9967df5..0da93e962496 100644 --- a/java/java-tests/testSrc/com/intellij/java/codeInspection/DataFlowInspectionTest.java +++ b/java/java-tests/testSrc/com/intellij/java/codeInspection/DataFlowInspectionTest.java @@ -698,4 +698,5 @@ public class DataFlowInspectionTest extends DataFlowInspectionTestCase { public void testBoxedDivisionComparison() { doTest(); } public void testUnknownComparedToNullable() { doTest(); } public void testCastInCatch() { doTest(); } + public void testInitArrayInConstructor() { doTest(); } }