Bug 572431 - Lef out scenario

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>
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 bcb28a1..36c96df 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 @@
 				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 2a8745f..e4d0bce 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 @@
 		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();