@@ -2786,7 +2786,6 @@ namespace ts {
27862786 function createTypeParameter(symbol?: Symbol) {
27872787 const type = <TypeParameter>createType(TypeFlags.TypeParameter);
27882788 if (symbol) type.symbol = symbol;
2789- type.calculatedFlags = CalculatedTypeFlags.HasCalculatedContainsTypeParameter | CalculatedTypeFlags.ContainsTypeParameter;
27902789 return type;
27912790 }
27922791
@@ -12610,7 +12609,7 @@ namespace ts {
1261012609 // the order in which things were checked.
1261112610 if (source.flags & (TypeFlags.Object | TypeFlags.Conditional) && source.aliasSymbol &&
1261212611 source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol &&
12613- !(source.calculatedFlags! & CalculatedTypeFlags.IsMarkerType || target.calculatedFlags! & CalculatedTypeFlags.IsMarkerType )) {
12612+ !(source.aliasTypeArgumentsContainsMarker || target.aliasTypeArgumentsContainsMarker )) {
1261412613 const variances = getAliasVariances(source.aliasSymbol);
1261512614 const varianceResult = relateVariances(source.aliasTypeArguments, target.aliasTypeArguments, variances);
1261612615 if (varianceResult !== undefined) {
@@ -12825,7 +12824,13 @@ namespace ts {
1282512824 return Ternary.False;
1282612825
1282712826 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));
1282912834 }
1283012835
1283112836 function relateVariances(sourceTypeArguments: ReadonlyArray<Type> | undefined, targetTypeArguments: ReadonlyArray<Type> | undefined, variances: Variance[]) {
@@ -12862,110 +12867,6 @@ namespace ts {
1286212867 }
1286312868 }
1286412869
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-
1296912870 // A type [P in S]: X is related to a type [Q in T]: Y if T is related to S and X' is
1297012871 // related to Y, where X' is an instantiation of X in which P is replaced with Q. Notice
1297112872 // that S and T are contra-variant whereas X and Y are co-variant.
@@ -13431,7 +13332,7 @@ namespace ts {
1343113332 const links = getSymbolLinks(symbol);
1343213333 return getVariancesWorker(links.typeParameters, links, (_links, param, marker) => {
1343313334 const type = getTypeAliasInstantiation(symbol, instantiateTypes(links.typeParameters!, makeUnaryTypeMapper(param, marker)));
13434- type.calculatedFlags! |= CalculatedTypeFlags.IsMarkerType ;
13335+ type.aliasTypeArgumentsContainsMarker = true ;
1343513336 return type;
1343613337 });
1343713338 }
0 commit comments