@@ -126,11 +126,6 @@ Expr *FailureDiagnostic::getBaseExprFor(Expr *anchor) const {
126
126
return nullptr ;
127
127
}
128
128
129
- Optional<SelectedOverload>
130
- FailureDiagnostic::getChoiceFor (ConstraintLocator *locator) const {
131
- return getOverloadChoiceIfAvailable (S.getCalleeLocator (locator));
132
- }
133
-
134
129
Type FailureDiagnostic::restoreGenericParameters (
135
130
Type type,
136
131
llvm::function_ref<void (GenericTypeParamType *, Type)> substitution) {
@@ -227,7 +222,7 @@ ValueDecl *RequirementFailure::getDeclRef() const {
227
222
return getAffectedDeclFromType (
228
223
getContextualType (getLocator ()->getAnchor ()));
229
224
230
- if (auto overload = getChoiceFor (getLocator ())) {
225
+ if (auto overload = getCalleeOverloadChoiceIfAvailable (getLocator ())) {
231
226
// If there is a declaration associated with this
232
227
// failure e.g. an overload choice of the call
233
228
// expression, let's see whether failure is
@@ -757,7 +752,7 @@ bool LabelingFailure::diagnoseAsNote() {
757
752
return " (" + str + " )" ;
758
753
};
759
754
760
- auto selectedOverload = getChoiceFor (getLocator ());
755
+ auto selectedOverload = getCalleeOverloadChoiceIfAvailable (getLocator ());
761
756
if (!selectedOverload)
762
757
return false ;
763
758
@@ -1311,7 +1306,7 @@ bool RValueTreatedAsLValueFailure::diagnoseAsError() {
1311
1306
}
1312
1307
1313
1308
bool RValueTreatedAsLValueFailure::diagnoseAsNote () {
1314
- auto overload = getChoiceFor (getLocator ());
1309
+ auto overload = getCalleeOverloadChoiceIfAvailable (getLocator ());
1315
1310
if (!(overload && overload->choice .isDecl ()))
1316
1311
return false ;
1317
1312
@@ -2003,8 +1998,8 @@ bool ContextualFailure::diagnoseAsError() {
2003
1998
case ConstraintLocator::RValueAdjustment: {
2004
1999
auto &cs = getConstraintSystem ();
2005
2000
2006
- auto overload = getChoiceFor (
2007
- cs. getConstraintLocator (anchor, ConstraintLocator::UnresolvedMember));
2001
+ auto overload = getOverloadChoiceIfAvailable (
2002
+ getConstraintLocator (anchor, ConstraintLocator::UnresolvedMember));
2008
2003
if (!(overload && overload->choice .isDecl ()))
2009
2004
return false ;
2010
2005
@@ -2067,7 +2062,7 @@ bool ContextualFailure::diagnoseAsError() {
2067
2062
}
2068
2063
2069
2064
bool ContextualFailure::diagnoseAsNote () {
2070
- auto overload = getChoiceFor (getLocator ());
2065
+ auto overload = getCalleeOverloadChoiceIfAvailable (getLocator ());
2071
2066
if (!(overload && overload->choice .isDecl ()))
2072
2067
return false ;
2073
2068
@@ -3495,7 +3490,7 @@ bool AllowTypeOrInstanceMemberFailure::diagnoseAsError() {
3495
3490
};
3496
3491
3497
3492
auto *baseLoc = cs.getConstraintLocator (ctorRef->getBase ());
3498
- if (auto selection = getChoiceFor (baseLoc)) {
3493
+ if (auto selection = getCalleeOverloadChoiceIfAvailable (baseLoc)) {
3499
3494
OverloadChoice choice = selection->choice ;
3500
3495
if (choice.isDecl () && isMutable (choice.getDecl ()) &&
3501
3496
!isCallArgument (initCall) &&
@@ -3906,7 +3901,7 @@ bool MissingArgumentsFailure::diagnoseAsError() {
3906
3901
3907
3902
diag.flush ();
3908
3903
3909
- if (auto selectedOverload = getChoiceFor (locator)) {
3904
+ if (auto selectedOverload = getCalleeOverloadChoiceIfAvailable (locator)) {
3910
3905
if (auto *decl = selectedOverload->choice .getDeclOrNull ()) {
3911
3906
emitDiagnostic (decl, diag::decl_declared_here, decl->getFullName ());
3912
3907
}
@@ -3917,7 +3912,7 @@ bool MissingArgumentsFailure::diagnoseAsError() {
3917
3912
3918
3913
bool MissingArgumentsFailure::diagnoseAsNote () {
3919
3914
auto *locator = getLocator ();
3920
- if (auto overload = getChoiceFor (locator)) {
3915
+ if (auto overload = getCalleeOverloadChoiceIfAvailable (locator)) {
3921
3916
auto *fn = resolveType (overload->openedType )->getAs <AnyFunctionType>();
3922
3917
auto loc = overload->choice .getDecl ()->getLoc ();
3923
3918
if (loc.isInvalid ())
@@ -4038,7 +4033,8 @@ bool MissingArgumentsFailure::diagnoseSingleMissingArgument() const {
4038
4033
.fixItInsert (insertLoc, insertText.str ());
4039
4034
}
4040
4035
4041
- if (auto selectedOverload = getChoiceFor (getLocator ())) {
4036
+ if (auto selectedOverload =
4037
+ getCalleeOverloadChoiceIfAvailable (getLocator ())) {
4042
4038
if (auto *decl = selectedOverload->choice .getDeclOrNull ()) {
4043
4039
emitDiagnostic (decl, diag::decl_declared_here, decl->getFullName ());
4044
4040
}
@@ -4158,7 +4154,7 @@ bool MissingArgumentsFailure::diagnoseInvalidTupleDestructuring() const {
4158
4154
if (!(argExpr && getType (argExpr)->getRValueType ()->is <TupleType>()))
4159
4155
return false ;
4160
4156
4161
- auto selectedOverload = getChoiceFor (locator);
4157
+ auto selectedOverload = getCalleeOverloadChoiceIfAvailable (locator);
4162
4158
if (!selectedOverload)
4163
4159
return false ;
4164
4160
@@ -4586,7 +4582,7 @@ bool ExtraneousArgumentsFailure::diagnoseAsError() {
4586
4582
4587
4583
emitDiagnostic (anchor->getLoc (), diag::extra_arguments_in_call, OS.str ());
4588
4584
4589
- if (auto overload = getChoiceFor (getLocator ())) {
4585
+ if (auto overload = getCalleeOverloadChoiceIfAvailable (getLocator ())) {
4590
4586
if (auto *decl = overload->choice .getDeclOrNull ()) {
4591
4587
emitDiagnostic (decl, diag::decl_declared_here, decl->getFullName ());
4592
4588
}
@@ -4596,7 +4592,7 @@ bool ExtraneousArgumentsFailure::diagnoseAsError() {
4596
4592
}
4597
4593
4598
4594
bool ExtraneousArgumentsFailure::diagnoseAsNote () {
4599
- auto overload = getChoiceFor (getLocator ());
4595
+ auto overload = getCalleeOverloadChoiceIfAvailable (getLocator ());
4600
4596
if (!(overload && overload->choice .isDecl ()))
4601
4597
return false ;
4602
4598
@@ -5234,7 +5230,7 @@ bool MutatingMemberRefOnImmutableBase::diagnoseAsError() {
5234
5230
}
5235
5231
5236
5232
bool InvalidTupleSplatWithSingleParameterFailure::diagnoseAsError () {
5237
- auto selectedOverload = getChoiceFor (getLocator ());
5233
+ auto selectedOverload = getCalleeOverloadChoiceIfAvailable (getLocator ());
5238
5234
if (!selectedOverload || !selectedOverload->choice .isDecl ())
5239
5235
return false ;
5240
5236
@@ -5699,7 +5695,7 @@ bool ExpandArrayIntoVarargsFailure::diagnoseAsError() {
5699
5695
}
5700
5696
5701
5697
bool ExpandArrayIntoVarargsFailure::diagnoseAsNote () {
5702
- auto overload = getChoiceFor (getLocator ());
5698
+ auto overload = getCalleeOverloadChoiceIfAvailable (getLocator ());
5703
5699
auto anchor = getAnchor ();
5704
5700
if (!overload || !anchor)
5705
5701
return false ;
@@ -5733,7 +5729,7 @@ bool ExtraneousCallFailure::diagnoseAsError() {
5733
5729
}
5734
5730
};
5735
5731
5736
- if (auto overload = getChoiceFor (cs. getCalleeLocator ( locator) )) {
5732
+ if (auto overload = getCalleeOverloadChoiceIfAvailable ( locator)) {
5737
5733
if (auto *decl = overload->choice .getDeclOrNull ()) {
5738
5734
if (auto *enumCase = dyn_cast<EnumElementDecl>(decl)) {
5739
5735
auto diagnostic = emitDiagnostic (
@@ -5766,13 +5762,12 @@ bool ExtraneousCallFailure::diagnoseAsError() {
5766
5762
5767
5763
bool InvalidUseOfTrailingClosure::diagnoseAsError () {
5768
5764
auto *anchor = getAnchor ();
5769
- auto &cs = getConstraintSystem ();
5770
5765
5771
5766
emitDiagnostic (anchor->getLoc (), diag::trailing_closure_bad_param,
5772
5767
getToType ())
5773
5768
.highlight (anchor->getSourceRange ());
5774
5769
5775
- if (auto overload = getChoiceFor (cs. getCalleeLocator ( getLocator () ))) {
5770
+ if (auto overload = getCalleeOverloadChoiceIfAvailable ( getLocator ())) {
5776
5771
if (auto *decl = overload->choice .getDeclOrNull ()) {
5777
5772
emitDiagnostic (decl, diag::decl_declared_here, decl->getFullName ());
5778
5773
}
@@ -6025,9 +6020,9 @@ bool AssignmentTypeMismatchFailure::diagnoseAsError() {
6025
6020
6026
6021
bool AssignmentTypeMismatchFailure::diagnoseAsNote () {
6027
6022
auto *anchor = getAnchor ();
6028
- auto &cs = getConstraintSystem ();
6029
6023
6030
- if (auto overload = getChoiceFor (cs.getConstraintLocator (anchor))) {
6024
+ if (auto overload =
6025
+ getCalleeOverloadChoiceIfAvailable (getConstraintLocator (anchor))) {
6031
6026
if (auto *decl = overload->choice .getDeclOrNull ()) {
6032
6027
emitDiagnostic (decl,
6033
6028
diag::cannot_convert_candidate_result_to_contextual_type,
0 commit comments