Skip to content

Commit a0085e1

Browse files
committed
[Diagnostics] NFC: Rename UncurriedCandidate -> OverloadCandidate
1 parent e20723f commit a0085e1

File tree

3 files changed

+34
-39
lines changed

3 files changed

+34
-39
lines changed

lib/Sema/CSDiag.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4146,7 +4146,7 @@ static bool diagnoseRawRepresentableMismatch(CalleeCandidateInfo &CCI,
41464146
auto arguments = decomposeArgType(argType, argLabels);
41474147

41484148
auto bestMatchKind = RawRepresentableMismatch::NotApplicable;
4149-
const UncurriedCandidate *bestMatchCandidate = nullptr;
4149+
const OverloadCandidate *bestMatchCandidate = nullptr;
41504150
KnownProtocolKind bestMatchProtocol;
41514151
size_t bestMatchIndex;
41524152

@@ -4341,7 +4341,7 @@ bool FailureDiagnosis::diagnoseSubscriptErrors(SubscriptExpr *SE,
43414341
auto decomposedBaseType = decomposeArgType(baseType, {Identifier()});
43424342
auto decomposedIndexType = decomposeArgType(indexType, argLabels);
43434343
calleeInfo.filterList(
4344-
[&](UncurriedCandidate cand) -> CalleeCandidateInfo::ClosenessResultTy {
4344+
[&](OverloadCandidate cand) -> CalleeCandidateInfo::ClosenessResultTy {
43454345
// Classify how close this match is. Non-subscript decls don't match.
43464346
auto subscriptDecl = dyn_cast_or_null<SubscriptDecl>(cand.getDecl());
43474347
if (!subscriptDecl ||
@@ -4402,7 +4402,7 @@ bool FailureDiagnosis::diagnoseSubscriptErrors(SubscriptExpr *SE,
44024402
// and more concrete expected type for this subscript decl, in order
44034403
// to diagnose a better error.
44044404
if (baseType && indexType->hasUnresolvedType()) {
4405-
UncurriedCandidate cand = calleeInfo.candidates[0];
4405+
auto cand = calleeInfo.candidates[0];
44064406
auto candType = baseType->getTypeOfMember(CS.DC->getParentModule(),
44074407
cand.getDecl(), nullptr);
44084408
if (auto *candFunc = candType->getAs<FunctionType>()) {
@@ -5125,7 +5125,7 @@ bool FailureDiagnosis::diagnoseSubscriptMisuse(ApplyExpr *callExpr) {
51255125
auto params = decomposeArgType(CS.getType(argExpr), argLabels);
51265126
using ClosenessPair = CalleeCandidateInfo::ClosenessResultTy;
51275127

5128-
candidateInfo.filterList([&](UncurriedCandidate cand) -> ClosenessPair {
5128+
candidateInfo.filterList([&](OverloadCandidate cand) -> ClosenessPair {
51295129
auto candFuncType = cand.getUncurriedFunctionType();
51305130
if (!candFuncType)
51315131
return {CC_GeneralMismatch, {}};
@@ -5443,7 +5443,7 @@ bool FailureDiagnosis::visitApplyExpr(ApplyExpr *callExpr) {
54435443
if (auto fn = fnType->getAs<AnyFunctionType>()) {
54445444
using Closeness = CalleeCandidateInfo::ClosenessResultTy;
54455445

5446-
calleeInfo.filterList([&](UncurriedCandidate candidate) -> Closeness {
5446+
calleeInfo.filterList([&](OverloadCandidate candidate) -> Closeness {
54475447
auto resultType = candidate.getResultType();
54485448
if (!resultType)
54495449
return {CC_GeneralMismatch, {}};

lib/Sema/CalleeCandidateInfo.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ static bool isSubstitutableFor(Type type, ArchetypeType *archetype,
5656
return true;
5757
}
5858

59-
UncurriedCandidate::UncurriedCandidate(ValueDecl *decl, bool skipCurriedSelf)
60-
: declOrExpr(decl), skipCurriedSelf(skipCurriedSelf), substituted(false) {
59+
OverloadCandidate::OverloadCandidate(ValueDecl *decl, bool skipCurriedSelf)
60+
: declOrExpr(decl), skipCurriedSelf(skipCurriedSelf), substituted(false) {
6161

6262
if (auto *PD = dyn_cast<ParamDecl>(decl)) {
6363
if (PD->hasValidSignature())
@@ -89,8 +89,8 @@ UncurriedCandidate::UncurriedCandidate(ValueDecl *decl, bool skipCurriedSelf)
8989
}
9090
}
9191

92-
ArrayRef<Identifier> UncurriedCandidate::getArgumentLabels(
93-
SmallVectorImpl<Identifier> &scratch) {
92+
ArrayRef<Identifier>
93+
OverloadCandidate::getArgumentLabels(SmallVectorImpl<Identifier> &scratch) {
9494
scratch.clear();
9595
if (auto decl = getDecl()) {
9696
if (auto func = dyn_cast<AbstractFunctionDecl>(decl)) {
@@ -136,7 +136,7 @@ ArrayRef<Identifier> UncurriedCandidate::getArgumentLabels(
136136
return scratch;
137137
}
138138

139-
void UncurriedCandidate::dump() const {
139+
void OverloadCandidate::dump() const {
140140
if (auto decl = getDecl())
141141
decl->dumpRef(llvm::errs());
142142
else
@@ -309,9 +309,8 @@ static bool findGenericSubstitutions(DeclContext *dc, Type paramType,
309309
/// Determine how close an argument list is to an already decomposed argument
310310
/// list. If the closeness is a miss by a single argument, then this returns
311311
/// information about that failure.
312-
CalleeCandidateInfo::ClosenessResultTy
313-
CalleeCandidateInfo::evaluateCloseness(UncurriedCandidate candidate,
314-
ArrayRef<AnyFunctionType::Param> actualArgs) {
312+
CalleeCandidateInfo::ClosenessResultTy CalleeCandidateInfo::evaluateCloseness(
313+
OverloadCandidate candidate, ArrayRef<AnyFunctionType::Param> actualArgs) {
315314
auto *dc = candidate.getDecl()
316315
? candidate.getDecl()->getInnermostDeclContext()
317316
: nullptr;
@@ -787,7 +786,7 @@ void CalleeCandidateInfo::collectCalleeCandidates(Expr *fn,
787786
void CalleeCandidateInfo::filterListArgs(ArrayRef<AnyFunctionType::Param> actualArgs) {
788787
// Now that we have the candidate list, figure out what the best matches from
789788
// the candidate list are, and remove all the ones that aren't at that level.
790-
filterList([&](UncurriedCandidate candidate) -> ClosenessResultTy {
789+
filterList([&](OverloadCandidate candidate) -> ClosenessResultTy {
791790
// If this isn't a function or isn't valid at this uncurry level, treat it
792791
// as a general mismatch.
793792
if (!candidate.hasParameters())
@@ -801,7 +800,7 @@ void CalleeCandidateInfo::filterContextualMemberList(Expr *argExpr) {
801800

802801
// If the argument is not present then we expect members without arguments.
803802
if (!argExpr) {
804-
return filterList([&](UncurriedCandidate candidate) -> ClosenessResultTy {
803+
return filterList([&](OverloadCandidate candidate) -> ClosenessResultTy {
805804
// If this candidate has no arguments, then we're a match.
806805
if (!candidate.hasParameters())
807806
return {CC_ExactMatch, {}};

lib/Sema/CalleeCandidateInfo.h

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,17 @@ namespace swift {
4545
CC_GeneralMismatch ///< Something else is wrong.
4646
};
4747

48-
/// This is a candidate for a callee, along with an uncurry level.
48+
/// This is a candidate for a callee.
4949
///
50-
/// The uncurry level specifies how far much of a curried value has already
51-
/// been applied. For example, in a funcdecl of:
52-
/// func f(a:Int)(b:Double) -> Int
53-
/// Uncurry level of 0 indicates that we're looking at the "a" argument, an
54-
/// uncurry level of 1 indicates that we're looking at the "b" argument.
50+
/// `skipCurriedSelf` specifies that function type associated with this
51+
/// candidate might have a curried self parameter which needs to be
52+
/// skipped.
5553
///
56-
/// entityType specifies a specific type to use for this decl/expr that may be
57-
/// more resolved than the concrete type. For example, it may have generic
54+
/// `entityType` specifies a specific type to use for this decl/expr that may
55+
/// be more resolved than the concrete type. For example, it may have generic
5856
/// arguments substituted in.
5957
///
60-
struct UncurriedCandidate {
58+
struct OverloadCandidate {
6159
PointerUnion<ValueDecl *, Expr*> declOrExpr;
6260
bool skipCurriedSelf;
6361
Type entityType;
@@ -70,12 +68,12 @@ namespace swift {
7068
//
7169
// FIXME: Clean this up.
7270
bool substituted;
73-
74-
UncurriedCandidate(ValueDecl *decl, bool skipCurriedSelf);
75-
UncurriedCandidate(Expr *expr, Type type)
76-
: declOrExpr(expr), skipCurriedSelf(false), entityType(type),
77-
substituted(true) {}
78-
71+
72+
OverloadCandidate(ValueDecl *decl, bool skipCurriedSelf);
73+
OverloadCandidate(Expr *expr, Type type)
74+
: declOrExpr(expr), skipCurriedSelf(false), entityType(type),
75+
substituted(true) {}
76+
7977
ValueDecl *getDecl() const {
8078
return declOrExpr.dyn_cast<ValueDecl*>();
8179
}
@@ -150,8 +148,8 @@ namespace swift {
150148
bool hasTrailingClosure;
151149

152150
/// This is the list of candidates identified.
153-
SmallVector<UncurriedCandidate, 4> candidates;
154-
151+
SmallVector<OverloadCandidate, 4> candidates;
152+
155153
/// This tracks how close the candidates are, after filtering.
156154
CandidateCloseness closeness = CC_GeneralMismatch;
157155

@@ -196,25 +194,23 @@ namespace swift {
196194

197195
using ClosenessResultTy = std::pair<CandidateCloseness, FailedArgumentInfo>;
198196
using ClosenessPredicate =
199-
const std::function<ClosenessResultTy(UncurriedCandidate)> &;
197+
const std::function<ClosenessResultTy(OverloadCandidate)> &;
200198

201199
/// After the candidate list is formed, it can be filtered down to discard
202200
/// obviously mismatching candidates and compute a "closeness" for the
203201
/// resultant set.
204202
ClosenessResultTy
205-
evaluateCloseness(UncurriedCandidate candidate,
203+
evaluateCloseness(OverloadCandidate candidate,
206204
ArrayRef<AnyFunctionType::Param> actualArgs);
207-
205+
208206
void filterListArgs(ArrayRef<AnyFunctionType::Param> actualArgs);
209207
void filterList(ClosenessPredicate predicate);
210208
void filterContextualMemberList(Expr *argExpr);
211209

212210
bool empty() const { return candidates.empty(); }
213211
unsigned size() const { return candidates.size(); }
214-
UncurriedCandidate operator[](unsigned i) const {
215-
return candidates[i];
216-
}
217-
212+
OverloadCandidate operator[](unsigned i) const { return candidates[i]; }
213+
218214
/// Given a set of parameter lists from an overload group, and a list of
219215
/// arguments, emit a diagnostic indicating any partially matching
220216
/// overloads.

0 commit comments

Comments
 (0)