diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/DataFlowInspectionBase.java b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/DataFlowInspectionBase.java index 2a97dc43093f..e02052817043 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/DataFlowInspectionBase.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/DataFlowInspectionBase.java @@ -303,7 +303,7 @@ public class DataFlowInspectionBase extends BaseJavaBatchLocalInspectionTool { } } - reportConstantPushes(runner, holder, visitor); + reportConstantPushes(runner, holder, visitor, reportedAnchors); reportNullableArguments(visitor, holder, reportedAnchors); reportNullableAssignments(visitor, holder, reportedAnchors); @@ -323,13 +323,14 @@ public class DataFlowInspectionBase extends BaseJavaBatchLocalInspectionTool { private void reportConstantPushes(StandardDataFlowRunner runner, ProblemsHolder holder, - DataFlowInstructionVisitor visitor) { + DataFlowInstructionVisitor visitor, + Set reportedAnchors) { for (Instruction instruction : runner.getInstructions()) { if (instruction instanceof PushInstruction) { PsiExpression place = ((PushInstruction)instruction).getPlace(); DfaValue value = ((PushInstruction)instruction).getValue(); Object constant = value instanceof DfaConstValue ? ((DfaConstValue)value).getValue() : null; - if (place instanceof PsiPolyadicExpression && constant instanceof Boolean) { + if (place instanceof PsiPolyadicExpression && constant instanceof Boolean && reportedAnchors.add(place)) { reportConstantCondition(holder, visitor, place, (Boolean)constant); } } diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/ReturningConstantExpression.java b/java/java-tests/testData/inspection/dataFlow/fixture/ReturningConstantExpression.java index 8fd77c8671cf..ba3ad71b6a0c 100644 --- a/java/java-tests/testData/inspection/dataFlow/fixture/ReturningConstantExpression.java +++ b/java/java-tests/testData/inspection/dataFlow/fixture/ReturningConstantExpression.java @@ -1,7 +1,7 @@ class BrokenAlignment { boolean smth() { - if (2 == 2) { + if (2 == 2) { return true; }