diff --git a/packages/pyright-internal/src/analyzer/typeUtils.ts b/packages/pyright-internal/src/analyzer/typeUtils.ts index a0ae76d86a13..4db9e8765ea9 100644 --- a/packages/pyright-internal/src/analyzer/typeUtils.ts +++ b/packages/pyright-internal/src/analyzer/typeUtils.ts @@ -2584,7 +2584,10 @@ export function removeParamSpecVariadicsFromFunction(type: FunctionType): Functi return type; } - return FunctionType.cloneRemoveParamSpecVariadics(type, argsParam.type); + return FunctionType.cloneRemoveParamSpecVariadics( + type, + TypeVarType.cloneForParamSpecAccess(argsParam.type, /* access */ undefined) + ); } function _expandVariadicUnpackedUnion(type: Type) { diff --git a/packages/pyright-internal/src/analyzer/types.ts b/packages/pyright-internal/src/analyzer/types.ts index 7f1d4701f3f8..bfc606d51112 100644 --- a/packages/pyright-internal/src/analyzer/types.ts +++ b/packages/pyright-internal/src/analyzer/types.ts @@ -1848,6 +1848,10 @@ export namespace FunctionType { newFunction.details.paramSpec = paramSpec; } + if (type.inferredReturnType) { + newFunction.inferredReturnType = type.inferredReturnType; + } + return newFunction; }