Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a9e0a77

Browse files
committedJul 27, 2019
Record full inference status in visitation cache
1 parent 1ea4008 commit a9e0a77

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed
 

‎src/compiler/checker.ts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15462,7 +15462,7 @@ namespace ts {
1546215462
let visited: Map<number>;
1546315463
let bivariant = false;
1546415464
let propagationType: Type;
15465-
let inferenceCount = 0;
15465+
let inferenceMatch = false;
1546615466
let inferenceIncomplete = false;
1546715467
let allowComplexConstraintInference = true;
1546815468
inferFromTypes(originalSource, originalTarget);
@@ -15576,7 +15576,7 @@ namespace ts {
1557615576
clearCachedInferences(inferences);
1557715577
}
1557815578
}
15579-
inferenceCount++;
15579+
inferenceMatch = true;
1558015580
return;
1558115581
}
1558215582
else {
@@ -15668,15 +15668,21 @@ namespace ts {
1566815668

1566915669
function invokeOnce(source: Type, target: Type, action: (source: Type, target: Type) => void) {
1567015670
const key = source.id + "," + target.id;
15671-
const count = visited && visited.get(key);
15672-
if (count !== undefined) {
15673-
inferenceCount += count;
15671+
const status = visited && visited.get(key);
15672+
if (status !== undefined) {
15673+
if (status & 1) inferenceMatch = true;
15674+
if (status & 2) inferenceIncomplete = true;
1567415675
return;
1567515676
}
1567615677
(visited || (visited = createMap<number>())).set(key, 0);
15677-
const startCount = inferenceCount;
15678+
const saveInferenceMatch = inferenceMatch;
15679+
const saveInferenceIncomplete = inferenceIncomplete;
15680+
inferenceMatch = false;
15681+
inferenceIncomplete = false;
1567815682
action(source, target);
15679-
visited.set(key, inferenceCount - startCount);
15683+
visited.set(key, (inferenceMatch ? 1 : 0) | (inferenceIncomplete ? 2 : 0));
15684+
inferenceMatch = inferenceMatch || saveInferenceMatch;
15685+
inferenceIncomplete = inferenceIncomplete || saveInferenceIncomplete;
1568015686
}
1568115687

1568215688
function inferFromMatchingType(source: Type, targets: Type[], matches: (s: Type, t: Type) => boolean) {
@@ -15759,9 +15765,11 @@ namespace ts {
1575915765
}
1576015766
else {
1576115767
for (let i = 0; i < sources.length; i++) {
15762-
const count = inferenceCount;
15768+
const saveInferenceMatch = inferenceMatch;
15769+
inferenceMatch = false;
1576315770
inferFromTypes(sources[i], t);
15764-
if (count !== inferenceCount) matched[i] = true;
15771+
if (inferenceMatch) matched[i] = true;
15772+
inferenceMatch = inferenceMatch || saveInferenceMatch;
1576515773
}
1576615774
}
1576715775
}

0 commit comments

Comments
 (0)
Please sign in to comment.