@@ -114,7 +114,7 @@ namespace ts {
114
114
115
115
let anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
116
116
// 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.
118
118
anyFunctionType.flags |= TypeFlags.ContainsAnyFunctionType;
119
119
120
120
let noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
@@ -3761,22 +3761,23 @@ namespace ts {
3761
3761
}
3762
3762
}
3763
3763
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 {
3768
3769
let result: TypeFlags = 0;
3769
3770
for (let type of types) {
3770
3771
result |= type.flags;
3771
3772
}
3772
- return result & TypeFlags.ContainsLiteralFlags ;
3773
+ return result & TypeFlags.PropagatingFlags ;
3773
3774
}
3774
3775
3775
3776
function createTypeReference(target: GenericType, typeArguments: Type[]): TypeReference {
3776
3777
let id = getTypeListId(typeArguments);
3777
3778
let type = target.instantiations[id];
3778
3779
if (!type) {
3779
- let flags = TypeFlags.Reference | getContainsLiteralFlagsOfTypes (typeArguments);
3780
+ let flags = TypeFlags.Reference | getPropagatingFlagsOfTypes (typeArguments);
3780
3781
type = target.instantiations[id] = <TypeReference>createObjectType(flags, target.symbol);
3781
3782
type.target = target;
3782
3783
type.typeArguments = typeArguments;
@@ -4030,7 +4031,7 @@ namespace ts {
4030
4031
let id = getTypeListId(elementTypes);
4031
4032
let type = tupleTypes[id];
4032
4033
if (!type) {
4033
- type = tupleTypes[id] = <TupleType>createObjectType(TypeFlags.Tuple | getContainsLiteralFlagsOfTypes (elementTypes));
4034
+ type = tupleTypes[id] = <TupleType>createObjectType(TypeFlags.Tuple | getPropagatingFlagsOfTypes (elementTypes));
4034
4035
type.elementTypes = elementTypes;
4035
4036
}
4036
4037
return type;
@@ -4179,7 +4180,7 @@ namespace ts {
4179
4180
let id = getTypeListId(typeSet);
4180
4181
let type = unionTypes[id];
4181
4182
if (!type) {
4182
- type = unionTypes[id] = <UnionType>createObjectType(TypeFlags.Union | getContainsLiteralFlagsOfTypes (typeSet));
4183
+ type = unionTypes[id] = <UnionType>createObjectType(TypeFlags.Union | getPropagatingFlagsOfTypes (typeSet));
4183
4184
type.types = typeSet;
4184
4185
}
4185
4186
return type;
@@ -4213,7 +4214,7 @@ namespace ts {
4213
4214
let id = getTypeListId(typeSet);
4214
4215
let type = intersectionTypes[id];
4215
4216
if (!type) {
4216
- type = intersectionTypes[id] = <IntersectionType>createObjectType(TypeFlags.Intersection | getContainsLiteralFlagsOfTypes (typeSet));
4217
+ type = intersectionTypes[id] = <IntersectionType>createObjectType(TypeFlags.Intersection | getPropagatingFlagsOfTypes (typeSet));
4217
4218
type.types = typeSet;
4218
4219
}
4219
4220
return type;
@@ -7103,7 +7104,7 @@ namespace ts {
7103
7104
let stringIndexType = getIndexType(IndexKind.String);
7104
7105
let numberIndexType = getIndexType(IndexKind.Number);
7105
7106
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 );
7107
7108
return result;
7108
7109
7109
7110
function getIndexType(kind: IndexKind) {
0 commit comments