@@ -15462,7 +15462,7 @@ namespace ts {
15462
15462
let visited: Map<number>;
15463
15463
let bivariant = false;
15464
15464
let propagationType: Type;
15465
- let inferenceCount = 0 ;
15465
+ let inferenceMatch = false ;
15466
15466
let inferenceIncomplete = false;
15467
15467
let allowComplexConstraintInference = true;
15468
15468
inferFromTypes(originalSource, originalTarget);
@@ -15576,7 +15576,7 @@ namespace ts {
15576
15576
clearCachedInferences(inferences);
15577
15577
}
15578
15578
}
15579
- inferenceCount++ ;
15579
+ inferenceMatch = true ;
15580
15580
return;
15581
15581
}
15582
15582
else {
@@ -15668,15 +15668,21 @@ namespace ts {
15668
15668
15669
15669
function invokeOnce(source: Type, target: Type, action: (source: Type, target: Type) => void) {
15670
15670
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;
15674
15675
return;
15675
15676
}
15676
15677
(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;
15678
15682
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;
15680
15686
}
15681
15687
15682
15688
function inferFromMatchingType(source: Type, targets: Type[], matches: (s: Type, t: Type) => boolean) {
@@ -15759,9 +15765,11 @@ namespace ts {
15759
15765
}
15760
15766
else {
15761
15767
for (let i = 0; i < sources.length; i++) {
15762
- const count = inferenceCount;
15768
+ const saveInferenceMatch = inferenceMatch;
15769
+ inferenceMatch = false;
15763
15770
inferFromTypes(sources[i], t);
15764
- if (count !== inferenceCount) matched[i] = true;
15771
+ if (inferenceMatch) matched[i] = true;
15772
+ inferenceMatch = inferenceMatch || saveInferenceMatch;
15765
15773
}
15766
15774
}
15767
15775
}
0 commit comments