File tree Expand file tree Collapse file tree 3 files changed +22
-21
lines changed Expand file tree Collapse file tree 3 files changed +22
-21
lines changed Original file line number Diff line number Diff line change @@ -6326,21 +6326,17 @@ void FailureDiagnosis::diagnoseAmbiguity(Expr *E) {
6326
6326
// / If an UnresolvedDotExpr, SubscriptMember, etc has been resolved by the
6327
6327
// / constraint system, return the decl that it references.
6328
6328
ValueDecl *ConstraintSystem::findResolvedMemberRef (ConstraintLocator *locator) {
6329
- auto *resolvedOverloadSets = this ->getResolvedOverloadSets ();
6330
- if (!resolvedOverloadSets) return nullptr ;
6331
-
6332
6329
// Search through the resolvedOverloadSets to see if we have a resolution for
6333
6330
// this member. This is an O(n) search, but only happens when producing an
6334
6331
// error diagnostic.
6335
- for (auto resolved = resolvedOverloadSets;
6336
- resolved; resolved = resolved->Previous ) {
6337
- if (resolved->Locator != locator) continue ;
6338
-
6339
- // We only handle the simplest decl binding.
6340
- if (resolved->Choice .getKind () != OverloadChoiceKind::Decl)
6341
- return nullptr ;
6342
- return resolved->Choice .getDecl ();
6343
- }
6344
-
6345
- return nullptr ;
6332
+ auto *overload = findSelectedOverloadFor (locator);
6333
+ if (!overload)
6334
+ return nullptr ;
6335
+
6336
+ // We only want to handle the simplest decl binding.
6337
+ auto choice = overload->Choice ;
6338
+ if (choice.getKind () != OverloadChoiceKind::Decl)
6339
+ return nullptr ;
6340
+
6341
+ return choice.getDecl ();
6346
6342
}
Original file line number Diff line number Diff line change @@ -144,13 +144,7 @@ class FailureDiagnostic {
144
144
// / by the constraint solver.
145
145
ResolvedOverloadSetListItem *
146
146
getResolvedOverload (ConstraintLocator *locator) const {
147
- auto resolvedOverload = CS.getResolvedOverloadSets ();
148
- while (resolvedOverload) {
149
- if (resolvedOverload->Locator == locator)
150
- return resolvedOverload;
151
- resolvedOverload = resolvedOverload->Previous ;
152
- }
153
- return nullptr ;
147
+ return CS.findSelectedOverloadFor (locator);
154
148
}
155
149
156
150
// / Retrive the constraint locator for the given anchor and
Original file line number Diff line number Diff line change @@ -1592,6 +1592,17 @@ class ConstraintSystem {
1592
1592
return resolvedOverloadSets;
1593
1593
}
1594
1594
1595
+ ResolvedOverloadSetListItem *
1596
+ findSelectedOverloadFor (ConstraintLocator *locator) const {
1597
+ auto resolvedOverload = getResolvedOverloadSets ();
1598
+ while (resolvedOverload) {
1599
+ if (resolvedOverload->Locator == locator)
1600
+ return resolvedOverload;
1601
+ resolvedOverload = resolvedOverload->Previous ;
1602
+ }
1603
+ return nullptr ;
1604
+ }
1605
+
1595
1606
ResolvedOverloadSetListItem *findSelectedOverloadFor (Expr *expr) const {
1596
1607
auto resolvedOverload = getResolvedOverloadSets ();
1597
1608
while (resolvedOverload) {
You can’t perform that action at this time.
0 commit comments