Simplified internal FunctionType.clone method. (#8121)

This commit is contained in:
Eric Traut 2024-06-11 19:29:53 -07:00 committed by GitHub
parent 1742c57f8d
commit f2e5ff87df
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1608,18 +1608,12 @@ export namespace FunctionType {
boundToType?: ClassType,
boundTypeVarScopeId?: TypeVarScopeId
): FunctionType {
const newFunction = create(
type.details.name,
type.details.fullName,
type.details.moduleName,
type.details.flags,
type.flags,
type.details.docString
);
const newFunction = TypeBase.cloneType(type);
newFunction.details = { ...type.details };
newFunction.boundToType = boundToType ?? type.boundToType;
newFunction.preBoundFlags = newFunction.details.flags;
newFunction.boundToType = boundToType;
newFunction.boundTypeVarScopeId = boundTypeVarScopeId;
if (stripFirstParam) {
if (type.details.parameters.length > 0) {
@ -1658,7 +1652,6 @@ export namespace FunctionType {
}
newFunction.inferredReturnType = type.inferredReturnType;
newFunction.boundTypeVarScopeId = boundTypeVarScopeId ?? type.boundTypeVarScopeId;
return newFunction;
}