Skip to content

Commit 0e273c3

Browse files
committed
Fix type parameter inference cache invalidation
1 parent b0f050f commit 0e273c3

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/compiler/checker.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15229,15 +15229,23 @@ namespace ts {
1522915229
const inference = inferences[i];
1523015230
if (t === inference.typeParameter) {
1523115231
if (fix && !inference.isFixed) {
15232+
clearCachedInferences(inferences);
1523215233
inference.isFixed = true;
15233-
inference.inferredType = undefined;
1523415234
}
1523515235
return getInferredType(context, i);
1523615236
}
1523715237
}
1523815238
return t;
1523915239
}
1524015240

15241+
function clearCachedInferences(inferences: InferenceInfo[]) {
15242+
for (const inference of inferences) {
15243+
if (!inference.isFixed) {
15244+
inference.inferredType = undefined;
15245+
}
15246+
}
15247+
}
15248+
1524115249
function createInferenceInfo(typeParameter: TypeParameter): InferenceInfo {
1524215250
return {
1524315251
typeParameter,
@@ -15517,17 +15525,17 @@ namespace ts {
1551715525
if (contravariant && !bivariant) {
1551815526
if (!contains(inference.contraCandidates, candidate)) {
1551915527
inference.contraCandidates = append(inference.contraCandidates, candidate);
15520-
inference.inferredType = undefined;
15528+
clearCachedInferences(inferences);
1552115529
}
1552215530
}
1552315531
else if (!contains(inference.candidates, candidate)) {
1552415532
inference.candidates = append(inference.candidates, candidate);
15525-
inference.inferredType = undefined;
15533+
clearCachedInferences(inferences);
1552615534
}
1552715535
}
1552815536
if (!(priority & InferencePriority.ReturnType) && target.flags & TypeFlags.TypeParameter && inference.topLevel && !isTypeParameterAtTopLevel(originalTarget, <TypeParameter>target)) {
1552915537
inference.topLevel = false;
15530-
inference.inferredType = undefined;
15538+
clearCachedInferences(inferences);
1553115539
}
1553215540
}
1553315541
return;

0 commit comments

Comments
 (0)