Skip to content

Commit f2e5ff8

Browse files
authored
Simplified internal FunctionType.clone method. (#8121)
1 parent 1742c57 commit f2e5ff8

File tree

1 file changed

+3
-10
lines changed
  • packages/pyright-internal/src/analyzer

1 file changed

+3
-10
lines changed

packages/pyright-internal/src/analyzer/types.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1608,18 +1608,12 @@ export namespace FunctionType {
16081608
boundToType?: ClassType,
16091609
boundTypeVarScopeId?: TypeVarScopeId
16101610
): FunctionType {
1611-
const newFunction = create(
1612-
type.details.name,
1613-
type.details.fullName,
1614-
type.details.moduleName,
1615-
type.details.flags,
1616-
type.flags,
1617-
type.details.docString
1618-
);
1611+
const newFunction = TypeBase.cloneType(type);
16191612

16201613
newFunction.details = { ...type.details };
1621-
newFunction.boundToType = boundToType ?? type.boundToType;
16221614
newFunction.preBoundFlags = newFunction.details.flags;
1615+
newFunction.boundToType = boundToType;
1616+
newFunction.boundTypeVarScopeId = boundTypeVarScopeId;
16231617

16241618
if (stripFirstParam) {
16251619
if (type.details.parameters.length > 0) {
@@ -1658,7 +1652,6 @@ export namespace FunctionType {
16581652
}
16591653

16601654
newFunction.inferredReturnType = type.inferredReturnType;
1661-
newFunction.boundTypeVarScopeId = boundTypeVarScopeId ?? type.boundTypeVarScopeId;
16621655

16631656
return newFunction;
16641657
}

0 commit comments

Comments
 (0)