Skip to content

Commit cffa515

Browse files
committed
Ensure we don't overwrite computed CouldContainTypeVariables in new optimization
1 parent e8c7927 commit cffa515

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/compiler/checker.ts

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

0 commit comments

Comments
 (0)