diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/ControlFlowAnalyzer.java b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/ControlFlowAnalyzer.java index 9315d1f5d3aa..34cf7603cb79 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/ControlFlowAnalyzer.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/ControlFlowAnalyzer.java @@ -1365,7 +1365,7 @@ public class ControlFlowAnalyzer extends JavaElementVisitor { condition.accept(this); generateBoxingUnboxingInstructionFor(condition, PsiType.BOOLEAN); PsiType type = expression.getType(); - addInstruction(new ConditionalGotoInstruction(elseOffset, true, condition)); + addInstruction(new ConditionalGotoInstruction(elseOffset, true, PsiUtil.skipParenthesizedExprDown(condition))); thenExpression.accept(this); generateBoxingUnboxingInstructionFor(thenExpression,type); diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/NoParenthesesWarnings.java b/java/java-tests/testData/inspection/dataFlow/fixture/NoParenthesesWarnings.java new file mode 100644 index 000000000000..2f5844fc214c --- /dev/null +++ b/java/java-tests/testData/inspection/dataFlow/fixture/NoParenthesesWarnings.java @@ -0,0 +1,7 @@ +class Fun { + void smthComplex() { + Object n = new Integer(1); + String result = ((n != null) ? n.toString() : ""); + } + +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java index e5b714799fc3..64782f805732 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java @@ -189,6 +189,7 @@ public class DataFlowInspectionTest extends LightCodeInsightFixtureTestCase { public void testLastConstantConditionInAnd() { doTest(); } public void testCompileTimeConstant() { doTest(); } + public void testNoParenthesesWarnings() { doTest(); } public void testTransientFinalField() { doTest(); } public void testRememberLocalTransientFieldState() { doTest(); }