Ensure that for statements promote properly in unreachable code.

Bug: https://github.com/dart-lang/sdk/issues/40009
Change-Id: I87ea8c8cd943c0c44d795aec084e012b3e2b4496
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166500
Reviewed-by: Johnni Winther <johnniwinther@google.com>
This commit is contained in:
Paul Berry 2020-10-07 20:01:34 +00:00 committed by commit-bot@chromium.org
parent c39b1642b6
commit 7aa9444059
2 changed files with 18 additions and 2 deletions

View file

@ -2882,7 +2882,7 @@ class _FlowAnalysisImpl<Node, Statement extends Node, Expression, Variable,
void for_conditionBegin(Node node) {
AssignedVariablesNodeInfo<Variable> info =
_assignedVariables._getInfoForNode(node);
_current = _current.conservativeJoin(info._written, info._captured);
_current = _current.conservativeJoin(info._written, info._captured).split();
}
@override
@ -2893,7 +2893,7 @@ class _FlowAnalysisImpl<Node, Statement extends Node, Expression, Variable,
FlowModel<Variable, Type> breakState = context._breakModel;
FlowModel<Variable, Type> falseCondition = context._conditionInfo.ifFalse;
_current = _join(falseCondition, breakState)
_current = _merge(falseCondition, breakState)
.inheritTested(typeOperations, _current);
}

View file

@ -53,6 +53,22 @@ doCondition(Object o) {
/*int*/ o;
}
forBreak(Object o) {
return;
for (;;) {
if (o is int) break;
}
/*int*/ o;
}
forContinue(Object o) {
return;
for (;; /*int*/ o) {
if (o is int) continue;
return;
}
}
ifIsNot(Object o) {
return;
if (o is! int) return;