From cffa5157a75f54a631e155c4ee3ba1d5d995b890 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Fri, 2 Jun 2023 16:12:25 -0700 Subject: [PATCH] Ensure we don't overwrite computed CouldContainTypeVariables in new optimization --- src/compiler/checker.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 72d7f692f9b43..f2f0aaff9c59a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -18800,8 +18800,12 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // If none of the type arguments for the outer type parameters contain type variables, it follows // that the instantiated type doesn't reference type variables. if (result.flags & TypeFlags.ObjectFlagsType && !((result as ObjectFlagsType).objectFlags & ObjectFlags.CouldContainTypeVariablesComputed)) { - (result as ObjectFlagsType).objectFlags |= ObjectFlags.CouldContainTypeVariablesComputed | - (some(typeArguments, couldContainTypeVariables) ? ObjectFlags.CouldContainTypeVariables : 0); + const resultCouldContainTypeVariables = some(typeArguments, couldContainTypeVariables); + // The above check may have caused the result's objectFlags to update if the result is referenced via typeArguments. + if (!((result as ObjectFlagsType).objectFlags & ObjectFlags.CouldContainTypeVariablesComputed)) { + (result as ObjectFlagsType).objectFlags |= ObjectFlags.CouldContainTypeVariablesComputed | + (resultCouldContainTypeVariables ? ObjectFlags.CouldContainTypeVariables : 0); + } } target.instantiations.set(id, result); }