@@ -114,7 +114,7 @@ namespace ts {
114114
115115 let anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
116116 // The anyFunctionType contains the anyFunctionType by definition. The flag is further propagated
117- // in getContainsLiteralFlagsOfTypes , and it is checked in inferFromTypes.
117+ // in getPropagatingFlagsOfTypes , and it is checked in inferFromTypes.
118118 anyFunctionType.flags |= TypeFlags.ContainsAnyFunctionType;
119119
120120 let noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
@@ -3761,22 +3761,23 @@ namespace ts {
37613761 }
37623762 }
37633763
3764- // This function is used to propagate widening flags when creating new object types references and union types.
3765- // It is only necessary to do so if a constituent type might be the undefined type, the null type, or the type
3766- // of an object literal (since those types have widening related information we need to track).
3767- function getContainsLiteralFlagsOfTypes(types: Type[]): TypeFlags {
3764+ // This function is used to propagate certain flags when creating new object type references and union types.
3765+ // It is only necessary to do so if a constituent type might be the undefined type, the null type, the type
3766+ // of an object literal or the anyFunctionType. This is because there are operations in the type checker
3767+ // that care about the presence of such types at arbitrary depth in a containing type.
3768+ function getPropagatingFlagsOfTypes(types: Type[]): TypeFlags {
37683769 let result: TypeFlags = 0;
37693770 for (let type of types) {
37703771 result |= type.flags;
37713772 }
3772- return result & TypeFlags.ContainsLiteralFlags ;
3773+ return result & TypeFlags.PropagatingFlags ;
37733774 }
37743775
37753776 function createTypeReference(target: GenericType, typeArguments: Type[]): TypeReference {
37763777 let id = getTypeListId(typeArguments);
37773778 let type = target.instantiations[id];
37783779 if (!type) {
3779- let flags = TypeFlags.Reference | getContainsLiteralFlagsOfTypes (typeArguments);
3780+ let flags = TypeFlags.Reference | getPropagatingFlagsOfTypes (typeArguments);
37803781 type = target.instantiations[id] = <TypeReference>createObjectType(flags, target.symbol);
37813782 type.target = target;
37823783 type.typeArguments = typeArguments;
@@ -4030,7 +4031,7 @@ namespace ts {
40304031 let id = getTypeListId(elementTypes);
40314032 let type = tupleTypes[id];
40324033 if (!type) {
4033- type = tupleTypes[id] = <TupleType>createObjectType(TypeFlags.Tuple | getContainsLiteralFlagsOfTypes (elementTypes));
4034+ type = tupleTypes[id] = <TupleType>createObjectType(TypeFlags.Tuple | getPropagatingFlagsOfTypes (elementTypes));
40344035 type.elementTypes = elementTypes;
40354036 }
40364037 return type;
@@ -4179,7 +4180,7 @@ namespace ts {
41794180 let id = getTypeListId(typeSet);
41804181 let type = unionTypes[id];
41814182 if (!type) {
4182- type = unionTypes[id] = <UnionType>createObjectType(TypeFlags.Union | getContainsLiteralFlagsOfTypes (typeSet));
4183+ type = unionTypes[id] = <UnionType>createObjectType(TypeFlags.Union | getPropagatingFlagsOfTypes (typeSet));
41834184 type.types = typeSet;
41844185 }
41854186 return type;
@@ -4213,7 +4214,7 @@ namespace ts {
42134214 let id = getTypeListId(typeSet);
42144215 let type = intersectionTypes[id];
42154216 if (!type) {
4216- type = intersectionTypes[id] = <IntersectionType>createObjectType(TypeFlags.Intersection | getContainsLiteralFlagsOfTypes (typeSet));
4217+ type = intersectionTypes[id] = <IntersectionType>createObjectType(TypeFlags.Intersection | getPropagatingFlagsOfTypes (typeSet));
42174218 type.types = typeSet;
42184219 }
42194220 return type;
@@ -7103,7 +7104,7 @@ namespace ts {
71037104 let stringIndexType = getIndexType(IndexKind.String);
71047105 let numberIndexType = getIndexType(IndexKind.Number);
71057106 let result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType);
7106- result.flags |= TypeFlags.ObjectLiteral | TypeFlags.FreshObjectLiteral | TypeFlags.ContainsObjectLiteral | (typeFlags & TypeFlags.ContainsLiteralFlags );
7107+ result.flags |= TypeFlags.ObjectLiteral | TypeFlags.FreshObjectLiteral | TypeFlags.ContainsObjectLiteral | (typeFlags & TypeFlags.PropagatingFlags );
71077108 return result;
71087109
71097110 function getIndexType(kind: IndexKind) {
0 commit comments