Skip to content

Commit f07db72

Browse files
committed
tweak cache key
1 parent 6d4258b commit f07db72

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/compiler/checker.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20374,16 +20374,16 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2037420374
error(currentNode, Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
2037520375
return errorType;
2037620376
}
20377-
mapper.instantiations ??= new Map();
20378-
const cached = mapper.instantiations.get(type.id);
20377+
const key = type.id + getAliasId(aliasSymbol, aliasTypeArguments);
20378+
const cached = (mapper.instantiations ??= new Map()).get(key);
2037920379
if (cached) {
2038020380
return cached;
2038120381
}
2038220382
totalInstantiationCount++;
2038320383
instantiationCount++;
2038420384
instantiationDepth++;
2038520385
const result = instantiateTypeWorker(type, mapper, aliasSymbol, aliasTypeArguments);
20386-
mapper.instantiations.set(type.id, result);
20386+
mapper.instantiations.set(key, result);
2038720387
instantiationDepth--;
2038820388
return result;
2038920389
}

src/compiler/types.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7029,11 +7029,11 @@ export const enum TypeMapKind {
70297029

70307030
/** @internal */
70317031
export type TypeMapper =
7032-
| { kind: TypeMapKind.Simple; source: Type; target: Type; instantiations?: Map<TypeId, Type>; }
7033-
| { kind: TypeMapKind.Array; sources: readonly Type[]; targets: readonly Type[] | undefined; instantiations?: Map<TypeId, Type>; }
7034-
| { kind: TypeMapKind.Deferred; sources: readonly Type[]; targets: (() => Type)[]; instantiations?: Map<TypeId, Type>; }
7035-
| { kind: TypeMapKind.Function; func: (t: Type) => Type; debugInfo?: () => string; instantiations?: Map<TypeId, Type>; }
7036-
| { kind: TypeMapKind.Composite | TypeMapKind.Merged; mapper1: TypeMapper; mapper2: TypeMapper; instantiations?: Map<TypeId, Type>; };
7032+
| { kind: TypeMapKind.Simple; source: Type; target: Type; instantiations?: Map<string, Type>; }
7033+
| { kind: TypeMapKind.Array; sources: readonly Type[]; targets: readonly Type[] | undefined; instantiations?: Map<string, Type>; }
7034+
| { kind: TypeMapKind.Deferred; sources: readonly Type[]; targets: (() => Type)[]; instantiations?: Map<string, Type>; }
7035+
| { kind: TypeMapKind.Function; func: (t: Type) => Type; debugInfo?: () => string; instantiations?: Map<string, Type>; }
7036+
| { kind: TypeMapKind.Composite | TypeMapKind.Merged; mapper1: TypeMapper; mapper2: TypeMapper; instantiations?: Map<string, Type>; };
70377037

70387038
// dprint-ignore
70397039
export const enum InferencePriority {

0 commit comments

Comments
 (0)