@@ -6,6 +6,7 @@ namespace ts {
66 let nextNodeId = 1;
77 let nextMergeId = 1;
88 let nextFlowId = 1;
9+ let nextCheckerId = 1;
910
1011 const enum IterationUse {
1112 AllowsSyncIterablesFlag = 1 << 0,
@@ -298,6 +299,7 @@ namespace ts {
298299 let instantiationDepth = 0;
299300 let constraintDepth = 0;
300301 let currentNode: Node | undefined;
302+ let checkerId: number;
301303
302304 const emptySymbols = createSymbolTable();
303305 const identityMapper: (type: Type) => Type = identity;
@@ -842,7 +844,6 @@ namespace ts {
842844 const flowLoopTypes: Type[][] = [];
843845 const sharedFlowNodes: FlowNode[] = [];
844846 const sharedFlowTypes: FlowType[] = [];
845- const flowNodeReachable: (boolean | undefined)[] = [];
846847 const potentialThisCollisions: Node[] = [];
847848 const potentialNewTargetCollisions: Node[] = [];
848849 const awaitedTypeStack: number[] = [];
@@ -16993,17 +16994,21 @@ namespace ts {
1699316994 }
1699416995
1699516996 function isReachableFlowNode(flow: FlowNode) {
16996- return isReachableFlowNodeWorker(flow, /*skipCacheCheck */ false);
16997+ return isReachableFlowNodeWorker(flow, /*noCacheCheck */ false);
1699716998 }
1699816999
1699917000 function isReachableFlowNodeWorker(flow: FlowNode, noCacheCheck: boolean): boolean {
1700017001 while (true) {
1700117002 const flags = flow.flags;
17002- if (flags & FlowFlags.Shared) {
17003+ if (flags & ( FlowFlags.Shared | FlowFlags.Assignment | FlowFlags.Label) ) {
1700317004 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;
1700717012 }
1700817013 noCacheCheck = false;
1700917014 }
@@ -32287,6 +32292,9 @@ namespace ts {
3228732292 }
3228832293
3228932294 function initializeTypeChecker() {
32295+ checkerId = nextCheckerId;
32296+ nextCheckerId++;
32297+
3229032298 // Bind all source files and propagate errors
3229132299 for (const file of host.getSourceFiles()) {
3229232300 bindSourceFile(file, compilerOptions);
0 commit comments