@@ -11490,20 +11490,21 @@ namespace ts {
1149011490 let symbolStack: Symbol[];
1149111491 let visited: Map<boolean>;
1149211492 let contravariant = false;
11493+ let propagationType: Type;
1149311494 inferFromTypes(originalSource, originalTarget);
1149411495
1149511496 function inferFromTypes(source: Type, target: Type) {
1149611497 if (!couldContainTypeVariables(target)) {
1149711498 return;
1149811499 }
11499- if (source === neverType || source === wildcardType ) {
11500- // We are inferring from 'never ' or the wildcard type . We want to infer this
11501- // type for every type parameter referenced in the target type, so we infer from
11502- // target to itself with a flag we check when recording candidates .
11503- const savePriority = priority ;
11504- priority | = source === neverType ? InferencePriority.Never : InferencePriority.Wildcard ;
11500+ if (source.flags & (TypeFlags.Any | TypeFlags.Never) && source !== silentNeverType ) {
11501+ // We are inferring from 'any ' or 'never' . We want to infer this type for every type parameter
11502+ // referenced in the target type, so we record the propagation type and infer from the target
11503+ // to itself. Then, as we find candidates we substitute the propagation type .
11504+ const savePropagationType = propagationType ;
11505+ propagationType = source;
1150511506 inferFromTypes(target, target);
11506- priority = savePriority ;
11507+ propagationType = savePropagationType ;
1150711508 return;
1150811509 }
1150911510 if (source.aliasSymbol && source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol) {
@@ -11567,16 +11568,13 @@ namespace ts {
1156711568 const inference = getInferenceInfoForType(target);
1156811569 if (inference) {
1156911570 if (!inference.isFixed) {
11570- const p = priority & InferencePriority.Mask;
11571- if (inference.priority === undefined || p < inference.priority) {
11571+ if (inference.priority === undefined || priority < inference.priority) {
1157211572 inference.candidates = undefined;
1157311573 inference.contraCandidates = undefined;
11574- inference.priority = p ;
11574+ inference.priority = priority ;
1157511575 }
11576- if (p === inference.priority) {
11577- const candidate = priority & InferencePriority.Never ? neverType :
11578- priority & InferencePriority.Wildcard ? wildcardType :
11579- source;
11576+ if (priority === inference.priority) {
11577+ const candidate = propagationType || source;
1158011578 if (contravariant) {
1158111579 inference.contraCandidates = append(inference.contraCandidates, candidate);
1158211580 }
0 commit comments