@@ -17753,18 +17753,18 @@ namespace ts {
17753
17753
// results for union and intersection types for performance reasons.
17754
17754
function couldContainTypeVariables(type: Type): boolean {
17755
17755
const objectFlags = getObjectFlags(type);
17756
- return !!(type.flags & TypeFlags.Instantiable ||
17756
+ if (objectFlags & ObjectFlags.CouldContainTypeVariablesComputed) {
17757
+ return !!(objectFlags & ObjectFlags.CouldContainTypeVariables);
17758
+ }
17759
+ const result = !!(type.flags & TypeFlags.Instantiable ||
17757
17760
objectFlags & ObjectFlags.Reference && ((<TypeReference>type).node || forEach(getTypeArguments(<TypeReference>type), couldContainTypeVariables)) ||
17758
17761
objectFlags & ObjectFlags.Anonymous && type.symbol && type.symbol.flags & (SymbolFlags.Function | SymbolFlags.Method | SymbolFlags.Class | SymbolFlags.TypeLiteral | SymbolFlags.ObjectLiteral) && type.symbol.declarations ||
17759
17762
objectFlags & (ObjectFlags.Mapped | ObjectFlags.ObjectRestType) ||
17760
- type.flags & TypeFlags.UnionOrIntersection && !(type.flags & TypeFlags.EnumLiteral) && couldUnionOrIntersectionContainTypeVariables(<UnionOrIntersectionType>type));
17761
- }
17762
-
17763
- function couldUnionOrIntersectionContainTypeVariables(type: UnionOrIntersectionType): boolean {
17764
- if (type.couldContainTypeVariables === undefined) {
17765
- type.couldContainTypeVariables = some(type.types, couldContainTypeVariables);
17763
+ type.flags & TypeFlags.UnionOrIntersection && !(type.flags & TypeFlags.EnumLiteral) && some((<UnionOrIntersectionType>type).types, couldContainTypeVariables));
17764
+ if (type.flags & TypeFlags.ObjectFlagsType) {
17765
+ (<ObjectFlagsType>type).objectFlags |= ObjectFlags.CouldContainTypeVariablesComputed | (result ? ObjectFlags.CouldContainTypeVariables : 0);
17766
17766
}
17767
- return type.couldContainTypeVariables ;
17767
+ return result ;
17768
17768
}
17769
17769
17770
17770
function isTypeParameterAtTopLevel(type: Type, typeParameter: TypeParameter): boolean {
0 commit comments