@@ -13658,7 +13658,7 @@ namespace ts {
13658
13658
return inference.priority! & InferencePriority.PriorityImpliesCombination ? getIntersectionType(inference.contraCandidates!) : getCommonSubtype(inference.contraCandidates!);
13659
13659
}
13660
13660
13661
- function getCovariantInference(inference: InferenceInfo, context: InferenceContext, signature: Signature) {
13661
+ function getCovariantInference(inference: InferenceInfo, signature: Signature) {
13662
13662
// Extract all object literal types and replace them with a single widened and normalized type.
13663
13663
const candidates = widenObjectLiteralCandidates(inference.candidates!);
13664
13664
// We widen inferred literal types if
@@ -13671,10 +13671,9 @@ namespace ts {
13671
13671
const baseCandidates = primitiveConstraint ? sameMap(candidates, getRegularTypeOfLiteralType) :
13672
13672
widenLiteralTypes ? sameMap(candidates, getWidenedLiteralType) :
13673
13673
candidates;
13674
- // If all inferences were made from contravariant positions, infer a common subtype. Otherwise, if
13675
- // union types were requested or if all inferences were made from the return type position, infer a
13676
- // union type. Otherwise, infer a common supertype.
13677
- const unwidenedType = context.flags & InferenceFlags.InferUnionTypes || inference.priority! & InferencePriority.PriorityImpliesCombination ?
13674
+ // If all inferences were made from a position that implies a combined result, infer a union type.
13675
+ // Otherwise, infer a common supertype.
13676
+ const unwidenedType = inference.priority! & InferencePriority.PriorityImpliesCombination ?
13678
13677
getUnionType(baseCandidates, UnionReduction.Subtype) :
13679
13678
getCommonSupertype(baseCandidates);
13680
13679
return getWidenedType(unwidenedType);
@@ -13694,7 +13693,7 @@ namespace ts {
13694
13693
inference.contraCandidates = undefined;
13695
13694
}
13696
13695
if (inference.candidates) {
13697
- inferredType = getCovariantInference(inference, context, signature);
13696
+ inferredType = getCovariantInference(inference, signature);
13698
13697
}
13699
13698
else if (context.flags & InferenceFlags.NoDefault) {
13700
13699
// We use silentNeverType as the wildcard that signals no inferences.
@@ -18633,7 +18632,7 @@ namespace ts {
18633
18632
18634
18633
// Instantiate a generic signature in the context of a non-generic signature (section 3.8.5 in TypeScript spec)
18635
18634
function instantiateSignatureInContextOf(signature: Signature, contextualSignature: Signature, contextualMapper?: TypeMapper, compareTypes?: TypeComparer): Signature {
18636
- const context = createInferenceContext(signature.typeParameters!, signature, InferenceFlags.InferUnionTypes , compareTypes);
18635
+ const context = createInferenceContext(signature.typeParameters!, signature, InferenceFlags.None , compareTypes);
18637
18636
const sourceSignature = contextualMapper ? instantiateSignature(contextualSignature, contextualMapper) : contextualSignature;
18638
18637
forEachMatchingParameterType(sourceSignature, signature, (source, target) => {
18639
18638
// Type parameters from outer context referenced by source type are fixed by instantiation of the source type
0 commit comments