@@ -17003,6 +17003,10 @@ namespace ts {
17003
17003
return result;
17004
17004
}
17005
17005
17006
+ function isUnlockedReachableFlowNode(flow: FlowNode) {
17007
+ return !(flow.flags & FlowFlags.PreFinally && (<PreFinallyFlow>flow).lock.locked) && isReachableFlowNodeWorker(flow, /*skipCacheCheck*/ false);
17008
+ }
17009
+
17006
17010
function isReachableFlowNodeWorker(flow: FlowNode, noCacheCheck: boolean): boolean {
17007
17011
while (true) {
17008
17012
if (flow === lastFlowNode) {
@@ -17017,8 +17021,8 @@ namespace ts {
17017
17021
}
17018
17022
noCacheCheck = false;
17019
17023
}
17020
- if (flags & (FlowFlags.Assignment | FlowFlags.Condition | FlowFlags.ArrayMutation | FlowFlags.PreFinally | FlowFlags.AfterFinally )) {
17021
- flow = (<FlowAssignment | FlowCondition | FlowArrayMutation | PreFinallyFlow | AfterFinallyFlow >flow).antecedent;
17024
+ if (flags & (FlowFlags.Assignment | FlowFlags.Condition | FlowFlags.ArrayMutation | FlowFlags.PreFinally)) {
17025
+ flow = (<FlowAssignment | FlowCondition | FlowArrayMutation | PreFinallyFlow>flow).antecedent;
17022
17026
}
17023
17027
else if (flags & FlowFlags.Call) {
17024
17028
const signature = getEffectsSignature((<FlowCall>flow).node);
@@ -17029,7 +17033,7 @@ namespace ts {
17029
17033
}
17030
17034
else if (flags & FlowFlags.BranchLabel) {
17031
17035
// A branching point is reachable if any branch is reachable.
17032
- return some((<FlowLabel>flow).antecedents, isReachableFlowNode );
17036
+ return some((<FlowLabel>flow).antecedents, isUnlockedReachableFlowNode );
17033
17037
}
17034
17038
else if (flags & FlowFlags.LoopLabel) {
17035
17039
// A loop is reachable if the control flow path that leads to the top is reachable.
@@ -17043,6 +17047,14 @@ namespace ts {
17043
17047
}
17044
17048
flow = (<FlowSwitchClause>flow).antecedent;
17045
17049
}
17050
+ else if (flags & FlowFlags.AfterFinally) {
17051
+ // Cache is unreliable once we start locking nodes
17052
+ lastFlowNode = undefined;
17053
+ (<AfterFinallyFlow>flow).locked = true;
17054
+ const result = isReachableFlowNodeWorker((<AfterFinallyFlow>flow).antecedent, /*skipCacheCheck*/ false);
17055
+ (<AfterFinallyFlow>flow).locked = false;
17056
+ return result;
17057
+ }
17046
17058
else {
17047
17059
return !(flags & FlowFlags.Unreachable);
17048
17060
}
0 commit comments