Skip to content

Commit 12e9c31

Browse files
committed
Fixed a theoretical bug in the code that detects unique type signatures. It wasn't correctly handling constructor methods.
1 parent e8250ba commit 12e9c31

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,9 @@ export class UniqueSignatureTracker {
240240
});
241241
}
242242

243-
addSignature(signature: FunctionType, offset: number) {
243+
addSignature(signature: FunctionType | OverloadedFunctionType, offset: number) {
244244
// If this function is part of a broader overload, use the overload instead.
245-
const effectiveSignature = signature.overloaded ?? signature;
245+
const effectiveSignature = isFunction(signature) ? signature.overloaded ?? signature : signature;
246246

247247
const existingSignature = this.findSignature(effectiveSignature);
248248
if (existingSignature) {
@@ -3627,8 +3627,6 @@ class UniqueFunctionSignatureTransformer extends TypeVarTransformer {
36273627
let updatedSourceType: Type = sourceType;
36283628
const existingSignature = this._signatureTracker.findSignature(sourceType);
36293629
if (existingSignature) {
3630-
const typeVarContext = new TypeVarContext(getTypeVarScopeId(sourceType));
3631-
36323630
let offsetIndex = existingSignature.expressionOffsets.findIndex(
36333631
(offset) => offset === this._expressionOffset
36343632
);
@@ -3637,6 +3635,8 @@ class UniqueFunctionSignatureTransformer extends TypeVarTransformer {
36373635
}
36383636

36393637
if (offsetIndex > 0) {
3638+
const typeVarContext = new TypeVarContext(getTypeVarScopeIds(sourceType));
3639+
36403640
// Create new type variables with the same scope but with
36413641
// different (unique) names.
36423642
sourceType.details.typeParameters.forEach((typeParam) => {

0 commit comments

Comments
 (0)