Skip to content

Commit 6656671

Browse files
committed
Proper contravariance in type parameter promotion
1 parent edf8954 commit 6656671

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/compiler/checker.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14511,10 +14511,9 @@ namespace ts {
1451114511
emptyObjectType;
1451214512
}
1451314513

14514-
function inferTypes(inferences: InferenceInfo[], originalSource: Type, originalTarget: Type, priority: InferencePriority = 0) {
14514+
function inferTypes(inferences: InferenceInfo[], originalSource: Type, originalTarget: Type, priority: InferencePriority = 0, contravariant = false) {
1451514515
let symbolStack: Symbol[];
1451614516
let visited: Map<boolean>;
14517-
let contravariant = false;
1451814517
let bivariant = false;
1451914518
let propagationType: Type;
1452014519
let allowComplexConstraintInference = true;
@@ -23474,7 +23473,7 @@ namespace ts {
2347423473
// contextual signature starting with an empty set of inference candidates.
2347523474
const inferences = map(context.inferences, info => createInferenceInfo(info.typeParameter));
2347623475
applyToParameterTypes(instantiatedSignature, contextualSignature, (source, target) => {
23477-
inferTypes(inferences, source, target);
23476+
inferTypes(inferences, source, target, /*priority*/ 0, /*contravariant*/ true);
2347823477
});
2347923478
if (some(inferences, hasInferenceCandidates)) {
2348023479
// We have inference candidates, indicating that one or more type parameters are referenced

0 commit comments

Comments
 (0)