@@ -322,9 +322,7 @@ class UnqualifiedLookupFactory {
322
322
323
323
bool isOutsideBodyOfFunction (const AbstractFunctionDecl *const AFD) const ;
324
324
325
- // / Check the generic parameters of our context.
326
- // / Return true if done with lookup
327
- bool addGenericParametersHereAndInEnclosingScopes (DeclContext *dc);
325
+ void addGenericParametersHereAndInEnclosingScopes (DeclContext *dc);
328
326
329
327
// / Consume generic parameters
330
328
void addGenericParametersForFunction (AbstractFunctionDecl *AFD);
@@ -335,7 +333,7 @@ class UnqualifiedLookupFactory {
335
333
bool addLocalVariableResults (DeclContext *dc);
336
334
337
335
// / Return true if finished with lookup
338
- bool setAsideUnavailableResults (const size_t startIndexOfInnerResults );
336
+ bool setAsideUnavailableResults (size_t firstPossiblyUnavailableResult );
339
337
340
338
void recordDependencyOnTopLevelName (DeclContext *topLevelContext,
341
339
DeclName name, bool isCascadingUse);
@@ -683,16 +681,18 @@ void UnqualifiedLookupFactory::finishLookingInContext(
683
681
lookupContextForThisContext,
684
682
placesToSearch, isCascadingUse});
685
683
#endif
686
- if (addGenericParameters == AddGenericParameters::Yes &&
687
- addGenericParametersHereAndInEnclosingScopes (lookupContextForThisContext))
688
- return ;
684
+ if (addGenericParameters == AddGenericParameters::Yes) {
685
+ addGenericParametersHereAndInEnclosingScopes (lookupContextForThisContext);
686
+ if (isFirstResultEnough ())
687
+ return ;
688
+ }
689
689
690
690
if (placesToSearch.hasValue () && !placesToSearch.getValue ().empty ()) {
691
- auto startIndexOfInnerResults = Results.size ();
691
+ auto firstPossiblyUnavailableResult = Results.size ();
692
692
placesToSearch.getValue ().addToResults (
693
693
Name, isCascadingUse.getValue (), baseNLOptions,
694
694
lookupContextForThisContext, Results);
695
- if (setAsideUnavailableResults (startIndexOfInnerResults ))
695
+ if (setAsideUnavailableResults (firstPossiblyUnavailableResult ))
696
696
return ;
697
697
}
698
698
@@ -919,7 +919,7 @@ UnqualifiedLookupFactory::getGenericParams(const DeclContext *const dc) {
919
919
return nullptr ;
920
920
}
921
921
922
- bool UnqualifiedLookupFactory::addGenericParametersHereAndInEnclosingScopes (
922
+ void UnqualifiedLookupFactory::addGenericParametersHereAndInEnclosingScopes (
923
923
DeclContext *dc) {
924
924
for (GenericParamList *dcGenericParams = getGenericParams (dc);
925
925
dcGenericParams;
@@ -929,9 +929,8 @@ bool UnqualifiedLookupFactory::addGenericParametersHereAndInEnclosingScopes(
929
929
930
930
recordCompletionOfAScope ();
931
931
if (isFirstResultEnough ())
932
- return true ;
932
+ break ;
933
933
}
934
- return false ;
935
934
}
936
935
937
936
void UnqualifiedLookupFactory::addGenericParametersForFunction (
@@ -978,10 +977,10 @@ void UnqualifiedLookupFactory::PlacesToSearch::addToResults(
978
977
}
979
978
980
979
bool UnqualifiedLookupFactory::setAsideUnavailableResults (
981
- const size_t startIndexOfInnerResults ) {
980
+ const size_t firstPossiblyUnavailableResult ) {
982
981
// An optimization:
983
- assert (Results.size () >= startIndexOfInnerResults );
984
- if (Results.size () == startIndexOfInnerResults )
982
+ assert (Results.size () >= firstPossiblyUnavailableResult );
983
+ if (Results.size () == firstPossiblyUnavailableResult )
985
984
return false ;
986
985
// Predicate that determines whether a lookup result should
987
986
// be unavailable except as a last-ditch effort.
@@ -992,7 +991,7 @@ bool UnqualifiedLookupFactory::setAsideUnavailableResults(
992
991
};
993
992
994
993
// If all of the results we found are unavailable, keep looking.
995
- auto begin = Results.begin () + startIndexOfInnerResults ;
994
+ auto begin = Results.begin () + firstPossiblyUnavailableResult ;
996
995
if (std::all_of (begin, Results.end (), unavailableLookupResult)) {
997
996
UnavailableInnerResults.append (begin, Results.end ());
998
997
Results.erase (begin, Results.end ());
0 commit comments