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:
Hamish Knight
2019-10-01 14:45:41 -07:00
parent b5a0d58dc0
commit ec45b24b63
4 changed files with 25 additions and 18 deletions

View File

@@ -3043,6 +3043,22 @@ bool constraints::isAutoClosureArgument(Expr *argExpr) {
return false;
}
bool constraints::hasAppliedSelf(ConstraintSystem &cs,
const OverloadChoice &choice) {
auto *decl = choice.getDeclOrNull();
if (!decl)
return false;
auto baseType = choice.getBaseType();
if (baseType)
baseType = cs.getFixedTypeRecursive(baseType, /*wantRValue=*/true);
// In most cases where we reference a declaration with a curried self
// parameter, it gets dropped from the type of the reference.
return decl->hasCurriedSelf() &&
doesMemberRefApplyCurriedSelf(baseType, decl);
}
bool constraints::conformsToKnownProtocol(ConstraintSystem &cs, Type type,
KnownProtocolKind protocol) {
if (auto *proto = cs.TC.getProtocol(SourceLoc(), protocol))