@@ -2786,7 +2786,6 @@ namespace ts {
2786
2786
function createTypeParameter(symbol?: Symbol) {
2787
2787
const type = <TypeParameter>createType(TypeFlags.TypeParameter);
2788
2788
if (symbol) type.symbol = symbol;
2789
- type.calculatedFlags = CalculatedTypeFlags.HasCalculatedContainsTypeParameter | CalculatedTypeFlags.ContainsTypeParameter;
2790
2789
return type;
2791
2790
}
2792
2791
@@ -12610,7 +12609,7 @@ namespace ts {
12610
12609
// the order in which things were checked.
12611
12610
if (source.flags & (TypeFlags.Object | TypeFlags.Conditional) && source.aliasSymbol &&
12612
12611
source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol &&
12613
- !(source.calculatedFlags! & CalculatedTypeFlags.IsMarkerType || target.calculatedFlags! & CalculatedTypeFlags.IsMarkerType )) {
12612
+ !(source.aliasTypeArgumentsContainsMarker || target.aliasTypeArgumentsContainsMarker )) {
12614
12613
const variances = getAliasVariances(source.aliasSymbol);
12615
12614
const varianceResult = relateVariances(source.aliasTypeArguments, target.aliasTypeArguments, variances);
12616
12615
if (varianceResult !== undefined) {
@@ -12825,7 +12824,13 @@ namespace ts {
12825
12824
return Ternary.False;
12826
12825
12827
12826
function isNonGeneric(type: Type) {
12828
- return !hasAggregatedCalculatedFlag(type, CalculatedTypeFlags.ContainsTypeParameter);
12827
+ // If we're already in identity relationship checking, we should use `isRelatedTo`
12828
+ // to catch the `Maybe` from an excessively deep type (which we then assume means
12829
+ // that the type could possibly contain a generic)
12830
+ if (relation === identityRelation) {
12831
+ return isRelatedTo(type, getPermissiveInstantiation(type)) === Ternary.True;
12832
+ }
12833
+ return isTypeIdenticalTo(type, getPermissiveInstantiation(type));
12829
12834
}
12830
12835
12831
12836
function relateVariances(sourceTypeArguments: ReadonlyArray<Type> | undefined, targetTypeArguments: ReadonlyArray<Type> | undefined, variances: Variance[]) {
@@ -12862,110 +12867,6 @@ namespace ts {
12862
12867
}
12863
12868
}
12864
12869
12865
- function hasAggregatedCalculatedFlag(type: Type, storageBit: CalculatedTypeFlags) {
12866
- const checkedBit = storageBit >> 1;
12867
- const visited = createMap<true>();
12868
- return visitType(type);
12869
-
12870
- function visitType(type: Type): boolean {
12871
- const id = "" + getTypeId(type);
12872
- if (visited.has(id)) return false;
12873
- visited.set(id, true);
12874
- const flags = type.flags;
12875
- if (type.calculatedFlags! & checkedBit) {
12876
- return !!(type.calculatedFlags! & storageBit);
12877
- }
12878
- if (flags & TypeFlags.Object) {
12879
- const objectFlags = (<ObjectType>type).objectFlags;
12880
- if (isGenericMappedType(type)) {
12881
- return cacheResult(type, visitType(getConstraintTypeFromMappedType(type)) || visitType(getTemplateTypeFromMappedType(type)));
12882
- }
12883
- else if (objectFlags & ObjectFlags.ReverseMapped) {
12884
- return cacheResult(type, visitType((type as ReverseMappedType).mappedType) ||
12885
- visitType((type as ReverseMappedType).source) ||
12886
- visitType((type as ReverseMappedType).constraintType));
12887
- }
12888
- else if (objectFlags & (ObjectFlags.Anonymous | ObjectFlags.Mapped | ObjectFlags.ClassOrInterface)) {
12889
- return cacheResult(type, visitStructuredType(type as StructuredType));
12890
- }
12891
- else if (objectFlags & ObjectFlags.Reference) {
12892
- const typeArguments = (<TypeReference>type).typeArguments;
12893
- return cacheResult(type, some(typeArguments, visitType));
12894
- }
12895
- }
12896
- else if (flags & TypeFlags.UnionOrIntersection) {
12897
- return cacheResult(type, some((type as UnionOrIntersectionType).types, visitType));
12898
- }
12899
- else if (flags & TypeFlags.Index) {
12900
- return cacheResult(type, visitType((type as IndexType).type));
12901
- }
12902
- else if (flags & TypeFlags.IndexedAccess) {
12903
- return cacheResult(type, visitType((type as IndexedAccessType).objectType) ||
12904
- visitType((type as IndexedAccessType).indexType));
12905
- }
12906
- else if (flags & TypeFlags.Conditional) {
12907
- return cacheResult(type, visitType((type as ConditionalType).checkType) ||
12908
- visitType((type as ConditionalType).extendsType) ||
12909
- visitType(getTrueTypeFromConditionalType(type as ConditionalType)) ||
12910
- visitType(getFalseTypeFromConditionalType(type as ConditionalType)));
12911
- }
12912
- else if (flags & TypeFlags.Substitution) {
12913
- return cacheResult(type, visitType((type as SubstitutionType).typeVariable) ||
12914
- visitType((type as SubstitutionType).substitute));
12915
- }
12916
- return false;
12917
- }
12918
-
12919
- function cacheResult(type: Type, result: boolean) {
12920
- type.calculatedFlags! |= checkedBit;
12921
- if (result) {
12922
- type.calculatedFlags! |= storageBit;
12923
- }
12924
- return result;
12925
- }
12926
-
12927
- function visitStructuredType(type: StructuredType) {
12928
- resolveStructuredTypeMembers(type);
12929
- const strIdx = getIndexInfoOfType(type, IndexKind.String);
12930
- if (strIdx) {
12931
- if (visitType(strIdx.type)) {
12932
- return true;
12933
- }
12934
- }
12935
- const numIdx = getIndexInfoOfType(type, IndexKind.Number);
12936
- if (numIdx) {
12937
- if (visitType(numIdx.type)) {
12938
- return true;
12939
- }
12940
- }
12941
- for (const sig of getSignaturesOfStructuredType(type, SignatureKind.Call)) {
12942
- if (visitSignature(sig)) {
12943
- return true;
12944
- }
12945
- }
12946
- for (const sig of getSignaturesOfStructuredType(type, SignatureKind.Construct)) {
12947
- if (visitSignature(sig)) {
12948
- return true;
12949
- }
12950
- }
12951
- for (const member of ((type as ResolvedType).properties || emptyArray)) {
12952
- if (visitType(getTypeOfSymbol(member))) {
12953
- return true;
12954
- }
12955
- }
12956
- return false;
12957
- }
12958
-
12959
- function visitSignature(sig: Signature) {
12960
- for (const param of sig.parameters) {
12961
- if (visitType(getTypeOfSymbol(param))) {
12962
- return true;
12963
- }
12964
- }
12965
- return visitType(getReturnTypeOfSignature(sig));
12966
- }
12967
- }
12968
-
12969
12870
// A type [P in S]: X is related to a type [Q in T]: Y if T is related to S and X' is
12970
12871
// related to Y, where X' is an instantiation of X in which P is replaced with Q. Notice
12971
12872
// that S and T are contra-variant whereas X and Y are co-variant.
@@ -13431,7 +13332,7 @@ namespace ts {
13431
13332
const links = getSymbolLinks(symbol);
13432
13333
return getVariancesWorker(links.typeParameters, links, (_links, param, marker) => {
13433
13334
const type = getTypeAliasInstantiation(symbol, instantiateTypes(links.typeParameters!, makeUnaryTypeMapper(param, marker)));
13434
- type.calculatedFlags! |= CalculatedTypeFlags.IsMarkerType ;
13335
+ type.aliasTypeArgumentsContainsMarker = true ;
13435
13336
return type;
13436
13337
});
13437
13338
}
0 commit comments