From d0e6c61fde3e739d1f72404c17d7f32d9754b354 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Thu, 30 Oct 2014 11:50:05 +0100 Subject: [PATCH] disable short circuits for unreachable statements detection (IDEA-58305; IDEA-70953; IDEA-70948) --- .../analysis/HighlightControlFlowUtil.java | 2 +- .../advHighlighting/Unreachable.java | 40 +++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightControlFlowUtil.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightControlFlowUtil.java index 697bf0e0e8a6..3f138a9114ad 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightControlFlowUtil.java +++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightControlFlowUtil.java @@ -80,7 +80,7 @@ public class HighlightControlFlowUtil { public static ControlFlow getControlFlowNoConstantEvaluate(PsiElement body) throws AnalysisCanceledException { LocalsOrMyInstanceFieldsControlFlowPolicy policy = LocalsOrMyInstanceFieldsControlFlowPolicy.getInstance(); - return ControlFlowFactory.getInstance(body.getProject()).getControlFlow(body, policy, false); + return ControlFlowFactory.getInstance(body.getProject()).getControlFlow(body, policy, false, false); } private static ControlFlow getControlFlow(PsiElement context) throws AnalysisCanceledException { diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/Unreachable.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/Unreachable.java index 9b419b3b4b08..3eed64027e46 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/Unreachable.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/Unreachable.java @@ -352,8 +352,48 @@ class NestedFinallyTest { } } +class Good0 { + private final int i; + Good0() { + while ((i = 1) != 0 && false) { + } + } +} +class Good1 { + void reachable() { + for (;true && true || false; ) { + reachable(); + } + } +} +class Good11 { + void good() { + for (;true || true;) { + good(); + } + } +} +class Good2 { + Good2() { + boolean b; + while (false && (b = false)) {} + } +} + +class Good3 { + static void main(String[] args) { + do { + } while (test() || true); + System.out.println("2"); + } + + static boolean test() { + System.out.println("1"); + return false; + } +}