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:
Eric Traut 2024-04-23 21:47:13 -07:00 committed by GitHub
parent 7c8e8ba8e0
commit d33a1051dd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 31 additions and 27 deletions

View File

@ -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;
}
}
}

View File

@ -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];
}