Ensure that try/catch statements promote properly in unreachable code.

Bug: https://github.com/dart-lang/sdk/issues/40009
Change-Id: Ie4b8809c6f37ff67891bc874c0c0ec10c70eb9fa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166660
Reviewed-by: Johnni Winther <johnniwinther@google.com>
This commit is contained in:
Paul Berry 2020-10-08 21:42:14 +00:00
parent ef1646697c
commit f51fb064cc
2 changed files with 22 additions and 1 deletions

View file

@ -3255,6 +3255,7 @@ class _FlowAnalysisImpl<Node, Statement extends Node, Expression, Variable,
@override
void tryCatchStatement_bodyBegin() {
_current = _current.split();
_stack.add(new _TryContext<Variable, Type>(_current));
}
@ -3301,7 +3302,7 @@ class _FlowAnalysisImpl<Node, Statement extends Node, Expression, Variable,
void tryCatchStatement_end() {
_TryContext<Variable, Type> context =
_stack.removeLast() as _TryContext<Variable, Type>;
_current = context._afterBodyAndCatches;
_current = context._afterBodyAndCatches.unsplit();
}
@override

View file

@ -201,3 +201,23 @@ switchPromoteInImplicitDefault(Object o, int i, Object p) {
}
/*int*/ o;
}
tryCatchPromoteInTry(Object o) {
return;
try {
if (o is! int) return;
} catch (_) {
return;
}
/*int*/ o;
}
tryCatchPromoteInCatch(Object o) {
return;
try {
return;
} catch (_) {
if (o is! int) return;
}
/*int*/ o;
}