mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 17:56:11 +00:00
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:
parent
ef1646697c
commit
f51fb064cc
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue