Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Arthanareeswaran2021-06-03 16:21:49 +0000
committerJay Arthanareeswaran2021-06-09 05:49:54 +0000
commit14a49912f4619af22219949b6c07b2e2758a32b5 (patch)
tree1992bdb6a0ad3f9575cf0ddb57681b3a18f3f51f
parent0fc92c07cc21c7828eda0293e01fda98392e50b8 (diff)
downloadeclipse.jdt.core-R4_20_maintenance.tar.gz
eclipse.jdt.core-R4_20_maintenance.tar.xz
eclipse.jdt.core-R4_20_maintenance.zip
Change-Id: I1cc9e153e9e79de32e8dbe1412daf048371f2875 Also-by: Jay Arthanareeswaran <jarthana@in.ibm.com> Signed-off-by: Stephan Herrmann <stephan.herrmann@berlin.de> Reviewed-on: https://git.eclipse.org/r/c/jdt/eclipse.jdt.core/+/181658 Tested-by: JDT Bot <jdt-bot@eclipse.org> Reviewed-by: Jay Arthanareeswaran <jarthana@in.ibm.com>
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/PatternMatching16Test.java26
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/InstanceOfExpression.java2
2 files changed, 27 insertions, 1 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/PatternMatching16Test.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/PatternMatching16Test.java
index bcb28a1428..36c96df9ea 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/PatternMatching16Test.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/PatternMatching16Test.java
@@ -3812,4 +3812,30 @@ public class PatternMatching16Test extends AbstractRegressionTest {
options);
}
+ public void testBug572431_6() {
+ Map<String, String> options = getCompilerOptions(false);
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"
+ + " static public void something () {\n"
+ + " boolean bool = true;\n"
+ + " Object object = null;\n"
+ + " for (int i = 0; i < 10; i++) {\n"
+ + " if (object instanceof String string) {\n"
+ + " System.out.println(i);\n"
+ + " } else if (bool) {\n"
+ + " if (i == 4) continue;\n"
+ + " System.out.println(i);\n"
+ + " }\n"
+ + " }\n"
+ + " }\n"
+ + " static public void main (String[] args) throws Exception {\n"
+ + " }\n"
+ + "}",
+ },
+ "",
+ options);
+
+ }
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/InstanceOfExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/InstanceOfExpression.java
index 2a8745f271..e4d0bcedff 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/InstanceOfExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/InstanceOfExpression.java
@@ -74,7 +74,7 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl
flowContext.recordUsingNullReference(currentScope, local,
this.expression, FlowContext.CAN_ONLY_NULL | FlowContext.IN_INSTANCEOF, flowInfo);
// no impact upon enclosing try context
- flowInfo = FlowInfo.conditional(initsWhenTrue, flowInfo.copy());
+ flowInfo = FlowInfo.conditional(initsWhenTrue.copy(), flowInfo.copy());
} else if (this.expression instanceof Reference) {
if (currentScope.compilerOptions().enableSyntacticNullAnalysisForFields) {
FieldBinding field = ((Reference)this.expression).lastFieldBinding();

Back to the top