Cache generic signature instantiations
This commit is contained in:
parent
ed4fead087
commit
61b9da548a
|
@ -4232,7 +4232,7 @@ namespace ts {
|
|||
for (const baseSig of baseSignatures) {
|
||||
const typeParamCount = baseSig.typeParameters ? baseSig.typeParameters.length : 0;
|
||||
if (typeParamCount === typeArgCount) {
|
||||
const sig = typeParamCount ? getSignatureInstantiation(baseSig, typeArguments) : cloneSignature(baseSig);
|
||||
const sig = typeParamCount ? createSignatureInstantiation(baseSig, typeArguments) : cloneSignature(baseSig);
|
||||
sig.typeParameters = classType.localTypeParameters;
|
||||
sig.resolvedReturnType = classType;
|
||||
result.push(sig);
|
||||
|
@ -4982,6 +4982,12 @@ namespace ts {
|
|||
}
|
||||
|
||||
function getSignatureInstantiation(signature: Signature, typeArguments: Type[]): Signature {
|
||||
const instantiations = signature.instantiations || (signature.instantiations = createMap<Signature>());
|
||||
const id = getTypeListId(typeArguments);
|
||||
return instantiations[id] || (instantiations[id] = createSignatureInstantiation(signature, typeArguments));
|
||||
}
|
||||
|
||||
function createSignatureInstantiation(signature: Signature, typeArguments: Type[]): Signature {
|
||||
return instantiateSignature(signature, createTypeMapper(signature.typeParameters, typeArguments), /*eraseTypeParameters*/ true);
|
||||
}
|
||||
|
||||
|
|
|
@ -2923,6 +2923,8 @@ namespace ts {
|
|||
isolatedSignatureType?: ObjectType; // A manufactured type that just contains the signature for purposes of signature comparison
|
||||
/* @internal */
|
||||
typePredicate?: TypePredicate;
|
||||
/* @internal */
|
||||
instantiations?: Map<Signature>; // Generic signature instantiation cache
|
||||
}
|
||||
|
||||
export const enum IndexKind {
|
||||
|
|
Loading…
Reference in a new issue