Skip to content

Commit 87cf117

Browse files
committed
[NFC] Sema: Add Solution::getCalleeOverloadChoice
1 parent 77ddc28 commit 87cf117

File tree

4 files changed

+24
-7
lines changed

4 files changed

+24
-7
lines changed

include/swift/Sema/ConstraintSystem.h

+10-1
Original file line numberDiff line numberDiff line change
@@ -1753,8 +1753,12 @@ class Solution {
17531753
return *getOverloadChoiceIfAvailable(locator);
17541754
}
17551755

1756-
/// Retrieve the overload choice associated with the given
1756+
/// Retrieve the overload choice for the callee associated with the given
17571757
/// locator.
1758+
SelectedOverload getCalleeOverloadChoice(ConstraintLocator *locator) const;
1759+
1760+
/// Retrieve the overload choice associated with the given
1761+
/// locator, if any.
17581762
std::optional<SelectedOverload>
17591763
getOverloadChoiceIfAvailable(ConstraintLocator *locator) const {
17601764
auto known = overloadChoices.find(locator);
@@ -1763,6 +1767,11 @@ class Solution {
17631767
return std::nullopt;
17641768
}
17651769

1770+
/// Retrieve the overload choice for the callee associated with the given
1771+
/// locator, if any.
1772+
std::optional<SelectedOverload>
1773+
getCalleeOverloadChoiceIfAvailable(ConstraintLocator *locator) const;
1774+
17661775
std::optional<SyntacticElementTarget>
17671776
getTargetFor(SyntacticElementTargetKey key) const;
17681777

lib/Sema/CSApply.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,15 @@ Solution::resolveConcreteDeclRef(ValueDecl *decl,
188188
return ConcreteDeclRef(decl, subst);
189189
}
190190

191+
SelectedOverload
192+
Solution::getCalleeOverloadChoice(ConstraintLocator *locator) const {
193+
return getOverloadChoice(getCalleeLocator(locator));
194+
}
195+
196+
std::optional<SelectedOverload>
197+
Solution::getCalleeOverloadChoiceIfAvailable(ConstraintLocator *locator) const {
198+
return getOverloadChoiceIfAvailable(getCalleeLocator(locator));
199+
}
191200

192201
ConstraintLocator *Solution::getCalleeLocator(ConstraintLocator *locator,
193202
bool lookThroughApply) const {

lib/Sema/CSDiagnostics.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -9364,10 +9364,9 @@ bool DefaultExprTypeMismatch::diagnoseAsError() {
93649364
emitDiagnostic(diag::cannot_convert_default_value_type_to_argument_type,
93659365
getFromType(), getToType(), paramIdx);
93669366

9367-
auto overload = getCalleeOverloadChoiceIfAvailable(locator);
9368-
assert(overload);
9367+
auto overload = getSolution().getCalleeOverloadChoice(locator);
93699368

9370-
auto *PD = getParameterList(overload->choice.getDecl())->get(paramIdx);
9369+
auto *PD = getParameterList(overload.choice.getDecl())->get(paramIdx);
93719370

93729371
auto note = emitDiagnosticAt(PD->getLoc(), diag::default_value_declared_here);
93739372

lib/Sema/CSDiagnostics.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,11 @@ class FailureDiagnostic {
149149
return S.getOverloadChoiceIfAvailable(locator);
150150
}
151151

152-
/// Retrieve overload choice resolved for a callee for the anchor
153-
/// of a given locator.
152+
/// Retrieve the overload choice for the callee associated with the given
153+
/// locator, if any.
154154
std::optional<SelectedOverload>
155155
getCalleeOverloadChoiceIfAvailable(ConstraintLocator *locator) const {
156-
return getOverloadChoiceIfAvailable(S.getCalleeLocator(locator));
156+
return S.getCalleeOverloadChoiceIfAvailable(locator);
157157
}
158158

159159
ConstraintLocator *

0 commit comments

Comments
 (0)