Fix type parameter inference cache invalidation
This commit is contained in:
parent
b0f050f4ee
commit
0e273c3e07
1 changed files with 12 additions and 4 deletions
|
@ -15229,8 +15229,8 @@ namespace ts {
|
|||
const inference = inferences[i];
|
||||
if (t === inference.typeParameter) {
|
||||
if (fix && !inference.isFixed) {
|
||||
clearCachedInferences(inferences);
|
||||
inference.isFixed = true;
|
||||
inference.inferredType = undefined;
|
||||
}
|
||||
return getInferredType(context, i);
|
||||
}
|
||||
|
@ -15238,6 +15238,14 @@ namespace ts {
|
|||
return t;
|
||||
}
|
||||
|
||||
function clearCachedInferences(inferences: InferenceInfo[]) {
|
||||
for (const inference of inferences) {
|
||||
if (!inference.isFixed) {
|
||||
inference.inferredType = undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function createInferenceInfo(typeParameter: TypeParameter): InferenceInfo {
|
||||
return {
|
||||
typeParameter,
|
||||
|
@ -15517,17 +15525,17 @@ namespace ts {
|
|||
if (contravariant && !bivariant) {
|
||||
if (!contains(inference.contraCandidates, candidate)) {
|
||||
inference.contraCandidates = append(inference.contraCandidates, candidate);
|
||||
inference.inferredType = undefined;
|
||||
clearCachedInferences(inferences);
|
||||
}
|
||||
}
|
||||
else if (!contains(inference.candidates, candidate)) {
|
||||
inference.candidates = append(inference.candidates, candidate);
|
||||
inference.inferredType = undefined;
|
||||
clearCachedInferences(inferences);
|
||||
}
|
||||
}
|
||||
if (!(priority & InferencePriority.ReturnType) && target.flags & TypeFlags.TypeParameter && inference.topLevel && !isTypeParameterAtTopLevel(originalTarget, <TypeParameter>target)) {
|
||||
inference.topLevel = false;
|
||||
inference.inferredType = undefined;
|
||||
clearCachedInferences(inferences);
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue