Ensure that while statements promote properly in unreachable code.

Bug: https://github.com/dart-lang/sdk/issues/40009
Change-Id: I492b465b08a0f00549e8e69390cead35af211e0b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166700
Reviewed-by: Johnni Winther <johnniwinther@google.com>
diff --git a/pkg/_fe_analyzer_shared/lib/src/flow_analysis/flow_analysis.dart b/pkg/_fe_analyzer_shared/lib/src/flow_analysis/flow_analysis.dart
index f29e2d8..fad64cc 100644
--- a/pkg/_fe_analyzer_shared/lib/src/flow_analysis/flow_analysis.dart
+++ b/pkg/_fe_analyzer_shared/lib/src/flow_analysis/flow_analysis.dart
@@ -3350,6 +3350,7 @@
 
   @override
   void whileStatement_conditionBegin(Node node) {
+    _current = _current.split();
     AssignedVariablesNodeInfo<Variable> info =
         _assignedVariables._getInfoForNode(node);
     _current = _current.conservativeJoin(info._written, info._captured);
@@ -3359,7 +3360,7 @@
   void whileStatement_end() {
     _WhileContext<Variable, Type> context =
         _stack.removeLast() as _WhileContext<Variable, Type>;
-    _current = _join(context._conditionInfo.ifFalse, context._breakModel)
+    _current = _merge(context._conditionInfo.ifFalse, context._breakModel)
         .inheritTested(typeOperations, _current);
   }
 
diff --git a/pkg/_fe_analyzer_shared/test/flow_analysis/type_promotion/data/promotion_in_dead_code.dart b/pkg/_fe_analyzer_shared/test/flow_analysis/type_promotion/data/promotion_in_dead_code.dart
index 733c471..354b5bf 100644
--- a/pkg/_fe_analyzer_shared/test/flow_analysis/type_promotion/data/promotion_in_dead_code.dart
+++ b/pkg/_fe_analyzer_shared/test/flow_analysis/type_promotion/data/promotion_in_dead_code.dart
@@ -221,3 +221,11 @@
   }
   /*int*/ o;
 }
+
+whileBreak(Object o) {
+  return;
+  while (true) {
+    if (o is int) break;
+  }
+  /*int*/ o;
+}