From 2b0a1d92dda37fb80420e80d1d3933d9287be21f Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Mon, 10 Jun 2024 19:39:33 -0700 Subject: [PATCH] Simplified FunctionType.cloneForSpecialization method. --- packages/pyright-internal/src/analyzer/types.ts | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/packages/pyright-internal/src/analyzer/types.ts b/packages/pyright-internal/src/analyzer/types.ts index 337151c2c..dcb989825 100644 --- a/packages/pyright-internal/src/analyzer/types.ts +++ b/packages/pyright-internal/src/analyzer/types.ts @@ -1689,25 +1689,15 @@ export namespace FunctionType { specializedTypes: SpecializedFunctionTypes, specializedInferredReturnType: Type | undefined ): FunctionType { - const newFunction = create( - type.details.name, - type.details.fullName, - type.details.moduleName, - type.details.flags, - type.flags, - type.details.docString - ); - newFunction.details = type.details; + const newFunction = TypeBase.cloneType(type); assert(specializedTypes.parameterTypes.length === type.details.parameters.length); if (specializedTypes.parameterDefaultArgs) { assert(specializedTypes.parameterDefaultArgs.length === type.details.parameters.length); } - newFunction.specializedTypes = specializedTypes; - if (specializedInferredReturnType) { - newFunction.inferredReturnType = specializedInferredReturnType; - } + newFunction.specializedTypes = specializedTypes; + newFunction.inferredReturnType = specializedInferredReturnType; return newFunction; }