@@ -6,6 +6,7 @@ namespace ts {
6
6
let nextNodeId = 1;
7
7
let nextMergeId = 1;
8
8
let nextFlowId = 1;
9
+ let nextCheckerId = 1;
9
10
10
11
const enum IterationUse {
11
12
AllowsSyncIterablesFlag = 1 << 0,
@@ -298,6 +299,7 @@ namespace ts {
298
299
let instantiationDepth = 0;
299
300
let constraintDepth = 0;
300
301
let currentNode: Node | undefined;
302
+ let checkerId: number;
301
303
302
304
const emptySymbols = createSymbolTable();
303
305
const identityMapper: (type: Type) => Type = identity;
@@ -842,7 +844,6 @@ namespace ts {
842
844
const flowLoopTypes: Type[][] = [];
843
845
const sharedFlowNodes: FlowNode[] = [];
844
846
const sharedFlowTypes: FlowType[] = [];
845
- const flowNodeReachable: (boolean | undefined)[] = [];
846
847
const potentialThisCollisions: Node[] = [];
847
848
const potentialNewTargetCollisions: Node[] = [];
848
849
const awaitedTypeStack: number[] = [];
@@ -16993,17 +16994,21 @@ namespace ts {
16993
16994
}
16994
16995
16995
16996
function isReachableFlowNode(flow: FlowNode) {
16996
- return isReachableFlowNodeWorker(flow, /*skipCacheCheck */ false);
16997
+ return isReachableFlowNodeWorker(flow, /*noCacheCheck */ false);
16997
16998
}
16998
16999
16999
17000
function isReachableFlowNodeWorker(flow: FlowNode, noCacheCheck: boolean): boolean {
17000
17001
while (true) {
17001
17002
const flags = flow.flags;
17002
- if (flags & FlowFlags.Shared) {
17003
+ if (flags & ( FlowFlags.Shared | FlowFlags.Assignment | FlowFlags.Label) ) {
17003
17004
if (!noCacheCheck) {
17004
- const id = getFlowNodeId(flow);
17005
- const reachable = flowNodeReachable[id];
17006
- return reachable !== undefined ? reachable : (flowNodeReachable[id] = isReachableFlowNodeWorker(flow, /*skipCacheCheck*/ true));
17005
+ if (flow.checkerId === checkerId) {
17006
+ return !!(flow.flags & FlowFlags.Reachable);
17007
+ }
17008
+ const reachable = isReachableFlowNodeWorker(flow, /*noCacheCheck*/ true);
17009
+ flow.checkerId = checkerId;
17010
+ flow.flags = (flow.flags & ~FlowFlags.Reachable) | (reachable ? FlowFlags.Reachable : 0);
17011
+ return reachable;
17007
17012
}
17008
17013
noCacheCheck = false;
17009
17014
}
@@ -32287,6 +32292,9 @@ namespace ts {
32287
32292
}
32288
32293
32289
32294
function initializeTypeChecker() {
32295
+ checkerId = nextCheckerId;
32296
+ nextCheckerId++;
32297
+
32290
32298
// Bind all source files and propagate errors
32291
32299
for (const file of host.getSourceFiles()) {
32292
32300
bindSourceFile(file, compilerOptions);
0 commit comments