Skip to content

Commit fb2ada0

Browse files
stereotype441Commit Queue
authored andcommitted
[flow analysis] Simplify reachability computation in attachFinally.
Previously, `attachFinally` took advantage of `Reachability.rebaseForward` to compute reachability after a `try/finally` statement. This was overkill, since `Reachability.rebaseForward` contains special logic to account for widely diverging reachability stacks, whereas `attachFinally` always deals with reachability stacks that have an immediate common parent. This change adds an assertion to verify that the reachability stacks always have an immediate common ancestor, and replaces the call to `Reachability.rebaseForward` with the equivalent direct logic. Making this change will simplify the process of writing a spec for flow analysis. Change-Id: Icd7d3ebc150d1836932efe3891b3ea1077134351 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/437300 Reviewed-by: Chloe Stefantsova <[email protected]> Commit-Queue: Paul Berry <[email protected]>
1 parent 0dbc8c0 commit fb2ada0

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pkg/_fe_analyzer_shared/lib/src/flow_analysis/flow_analysis.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2708,7 +2708,11 @@ class FlowModel<Type extends Object> {
27082708

27092709
// Code that follows the `try/finally` is reachable iff the end of the `try`
27102710
// block is reachable _and_ the end of the `finally` block is reachable.
2711-
Reachability newReachable = afterFinally.reachable.rebaseForward(reachable);
2711+
assert(identical(reachable.parent, afterFinally.reachable.parent));
2712+
Reachability newReachable =
2713+
afterFinally.reachable.locallyReachable
2714+
? reachable
2715+
: reachable.setUnreachable();
27122716

27132717
// Consider each promotion key that is common to all three models.
27142718
FlowModel<Type> result = setReachability(newReachable);

0 commit comments

Comments
 (0)