Skip to content

Commit e3c5209

Browse files
authored
Ensure we don't overwrite computed CouldContainTypeVariables in new optimization (#54507)
1 parent 160d1b7 commit e3c5209

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/compiler/checker.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18801,8 +18801,12 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
1880118801
// If none of the type arguments for the outer type parameters contain type variables, it follows
1880218802
// that the instantiated type doesn't reference type variables.
1880318803
if (result.flags & TypeFlags.ObjectFlagsType && !((result as ObjectFlagsType).objectFlags & ObjectFlags.CouldContainTypeVariablesComputed)) {
18804-
(result as ObjectFlagsType).objectFlags |= ObjectFlags.CouldContainTypeVariablesComputed |
18805-
(some(typeArguments, couldContainTypeVariables) ? ObjectFlags.CouldContainTypeVariables : 0);
18804+
const resultCouldContainTypeVariables = some(typeArguments, couldContainTypeVariables);
18805+
// The above check may have caused the result's objectFlags to update if the result is referenced via typeArguments.
18806+
if (!((result as ObjectFlagsType).objectFlags & ObjectFlags.CouldContainTypeVariablesComputed)) {
18807+
(result as ObjectFlagsType).objectFlags |= ObjectFlags.CouldContainTypeVariablesComputed |
18808+
(resultCouldContainTypeVariables ? ObjectFlags.CouldContainTypeVariables : 0);
18809+
}
1880618810
}
1880718811
target.instantiations.set(id, result);
1880818812
}

0 commit comments

Comments
 (0)