@@ -4239,17 +4239,6 @@ namespace ts {
4239
4239
return mapper;
4240
4240
}
4241
4241
4242
- function fixTypeParametersAfterInferringFromContextualParameterTypes(context: InferenceContext): void {
4243
- for (let i = 0; i < context.typeParameters.length; i++) {
4244
- let typeParameterInfo = context.inferences[i];
4245
- if (typeParameterInfo.fixAfterInferringFromContextualParameterType) {
4246
- typeParameterInfo.fixAfterInferringFromContextualParameterType = false;
4247
- typeParameterInfo.isFixed = true;
4248
- getInferredType(context, i);
4249
- }
4250
- }
4251
- }
4252
-
4253
4242
function identityMapper(type: Type): Type {
4254
4243
return type;
4255
4244
}
@@ -5412,8 +5401,7 @@ namespace ts {
5412
5401
let inferences: TypeInferences[] = [];
5413
5402
for (let unused of typeParameters) {
5414
5403
inferences.push({
5415
- primary: undefined, secondary: undefined,
5416
- isFixed: false, fixAfterInferringFromContextualParameterType: false
5404
+ primary: undefined, secondary: undefined, isFixed: false
5417
5405
});
5418
5406
}
5419
5407
return {
@@ -5424,7 +5412,7 @@ namespace ts {
5424
5412
};
5425
5413
}
5426
5414
5427
- function inferTypes(context: InferenceContext, source: Type, target: Type, inferringFromContextuallyTypedParameter: boolean ) {
5415
+ function inferTypes(context: InferenceContext, source: Type, target: Type) {
5428
5416
let sourceStack: Type[];
5429
5417
let targetStack: Type[];
5430
5418
let depth = 0;
@@ -5463,9 +5451,6 @@ namespace ts {
5463
5451
if (!contains(candidates, source)) {
5464
5452
candidates.push(source);
5465
5453
}
5466
- if (inferringFromContextuallyTypedParameter) {
5467
- inferences.fixAfterInferringFromContextualParameterType = true;
5468
- }
5469
5454
}
5470
5455
return;
5471
5456
}
@@ -7854,7 +7839,7 @@ namespace ts {
7854
7839
let context = createInferenceContext(signature.typeParameters, /*inferUnionTypes*/ true);
7855
7840
forEachMatchingParameterType(contextualSignature, signature, (source, target) => {
7856
7841
// Type parameters from outer context referenced by source type are fixed by instantiation of the source type
7857
- inferTypes(context, instantiateType(source, contextualMapper), target, false );
7842
+ inferTypes(context, instantiateType(source, contextualMapper), target);
7858
7843
});
7859
7844
return getSignatureInstantiation(signature, getInferredTypes(context));
7860
7845
}
@@ -7904,7 +7889,7 @@ namespace ts {
7904
7889
argType = checkExpressionWithContextualType(arg, paramType, mapper);
7905
7890
}
7906
7891
7907
- inferTypes(context, argType, paramType, false );
7892
+ inferTypes(context, argType, paramType);
7908
7893
}
7909
7894
}
7910
7895
@@ -7919,7 +7904,7 @@ namespace ts {
7919
7904
if (excludeArgument[i] === false) {
7920
7905
let arg = args[i];
7921
7906
let paramType = getTypeAtPosition(signature, i);
7922
- inferTypes(context, checkExpressionWithContextualType(arg, paramType, inferenceMapper), paramType, false );
7907
+ inferTypes(context, checkExpressionWithContextualType(arg, paramType, inferenceMapper), paramType);
7923
7908
}
7924
7909
}
7925
7910
}
@@ -8823,8 +8808,7 @@ namespace ts {
8823
8808
parameterLinks.type = instantiateType(contextualType, mapper);
8824
8809
}
8825
8810
else if (isInferentialContext(mapper)) {
8826
- inferTypes(mapper.context, parameterLinks.type, contextualType, true);
8827
- fixTypeParametersAfterInferringFromContextualParameterTypes(mapper.context);
8811
+ inferTypes(mapper.context, parameterLinks.type, instantiateType(contextualType, mapper));
8828
8812
}
8829
8813
}
8830
8814
0 commit comments