mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Use hasAppliedSelf in getFunctionArgApplyInfo
`callee->hasCurriedSelf()` isn't the correct check here when we have an argument mismatch for the self parameter in a curried application.
This commit is contained in:
@@ -221,12 +221,12 @@ FailureDiagnostic::getFunctionArgApplyInfo(ConstraintLocator *locator) const {
|
||||
if (!argExpr)
|
||||
return None;
|
||||
|
||||
ValueDecl *callee = nullptr;
|
||||
Optional<OverloadChoice> choice;
|
||||
Type rawFnType;
|
||||
if (auto overload = getChoiceFor(argLocator)) {
|
||||
// If we have resolved an overload for the callee, then use that to get the
|
||||
// function type and callee.
|
||||
callee = overload->choice.getDeclOrNull();
|
||||
choice = overload->choice;
|
||||
rawFnType = overload->openedType;
|
||||
} else {
|
||||
// If we didn't resolve an overload for the callee, we must be dealing with
|
||||
@@ -249,6 +249,7 @@ FailureDiagnostic::getFunctionArgApplyInfo(ConstraintLocator *locator) const {
|
||||
// Resolve the interface type for the function. Note that this may not be a
|
||||
// function type, for example it could be a generic parameter.
|
||||
Type fnInterfaceType;
|
||||
auto *callee = choice ? choice->getDeclOrNull() : nullptr;
|
||||
if (callee && callee->hasInterfaceType()) {
|
||||
// If we have a callee with an interface type, we can use it. This is
|
||||
// preferable to resolveInterfaceType, as this will allow us to get a
|
||||
@@ -261,7 +262,7 @@ FailureDiagnostic::getFunctionArgApplyInfo(ConstraintLocator *locator) const {
|
||||
fnInterfaceType = callee->getInterfaceType();
|
||||
|
||||
// Strip off the curried self parameter if necessary.
|
||||
if (callee->hasCurriedSelf())
|
||||
if (hasAppliedSelf(cs, *choice))
|
||||
fnInterfaceType = fnInterfaceType->castTo<AnyFunctionType>()->getResult();
|
||||
|
||||
if (auto *fn = fnInterfaceType->getAs<AnyFunctionType>()) {
|
||||
|
||||
Reference in New Issue
Block a user