Skip to content

Commit e7f415d

Browse files
committed
Merge pull request #7163 from Microsoft/cachePairs
do not make inferences with the same source\target pair multiple times
1 parent 243440a commit e7f415d

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/compiler/checker.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6446,6 +6446,7 @@ namespace ts {
64466446
let targetStack: Type[];
64476447
let depth = 0;
64486448
let inferiority = 0;
6449+
const visited: Map<boolean> = {};
64496450
inferFromTypes(source, target);
64506451

64516452
function isInProcess(source: Type, target: Type) {
@@ -6575,6 +6576,12 @@ namespace ts {
65756576
return;
65766577
}
65776578

6579+
const key = source.id + "," + target.id;
6580+
if (hasProperty(visited, key)) {
6581+
return;
6582+
}
6583+
visited[key] = true;
6584+
65786585
if (depth === 0) {
65796586
sourceStack = [];
65806587
targetStack = [];

0 commit comments

Comments
 (0)