mirror of
https://github.com/microsoft/pyright.git
synced 2024-09-11 07:55:56 +03:00
Fixed bug that leads to false negative when binding an object to an overloaded method where all of the overloads have incompatible self
parameter types. This addresses #7742. (#7755)
This commit is contained in:
parent
7c8e8ba8e0
commit
d33a1051dd
@ -26657,32 +26657,36 @@ export function createTypeEvaluator(
|
||||
: firstParamType
|
||||
);
|
||||
}
|
||||
} else if (
|
||||
!assignType(
|
||||
memberTypeFirstParamType,
|
||||
firstParamType,
|
||||
diag?.createAddendum(),
|
||||
typeVarContext,
|
||||
/* srcTypeVarContext */ undefined,
|
||||
AssignTypeFlags.AllowUnspecifiedTypeArguments,
|
||||
recursionCount
|
||||
)
|
||||
) {
|
||||
} else {
|
||||
const subDiag = diag?.createAddendum();
|
||||
|
||||
if (
|
||||
memberTypeFirstParam.name &&
|
||||
!memberTypeFirstParam.isNameSynthesized &&
|
||||
memberTypeFirstParam.hasDeclaredType
|
||||
!assignType(
|
||||
memberTypeFirstParamType,
|
||||
firstParamType,
|
||||
subDiag?.createAddendum(),
|
||||
typeVarContext,
|
||||
/* srcTypeVarContext */ undefined,
|
||||
AssignTypeFlags.AllowUnspecifiedTypeArguments,
|
||||
recursionCount
|
||||
)
|
||||
) {
|
||||
if (diag) {
|
||||
diag.addMessage(
|
||||
LocMessage.bindTypeMismatch().format({
|
||||
type: printType(baseType),
|
||||
methodName: memberType.details.name || '<anonymous>',
|
||||
paramName: memberTypeFirstParam.name,
|
||||
})
|
||||
);
|
||||
if (
|
||||
memberTypeFirstParam.name &&
|
||||
!memberTypeFirstParam.isNameSynthesized &&
|
||||
memberTypeFirstParam.hasDeclaredType
|
||||
) {
|
||||
if (subDiag) {
|
||||
subDiag.addMessage(
|
||||
LocMessage.bindTypeMismatch().format({
|
||||
type: printType(baseType),
|
||||
methodName: memberType.details.name || '<anonymous>',
|
||||
paramName: memberTypeFirstParam.name,
|
||||
})
|
||||
);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -505,6 +505,10 @@ export function mapSignatures(
|
||||
}
|
||||
});
|
||||
|
||||
if (newSignatures.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// Add the unmodified implementation if it's present.
|
||||
const implementation = OverloadedFunctionType.getImplementation(type);
|
||||
if (implementation) {
|
||||
@ -515,10 +519,6 @@ export function mapSignatures(
|
||||
return type;
|
||||
}
|
||||
|
||||
if (newSignatures.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (newSignatures.length === 1) {
|
||||
return newSignatures[0];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user