@@ -264,8 +264,9 @@ class UnqualifiedLookupFactory {
264
264
Optional<bool > isCascadingUse);
265
265
266
266
// / Return true if done with lookup.
267
- bool isFinishedWithLookupNowThatIsAboutToLookForOuterResults (
268
- bool noMoreOuterResults = false );
267
+ bool isFinishedWithLookupNowThatIsAboutToLookForOuterResults ();
268
+
269
+ void setIndexOfFirstOuterResultIfNotSetAlready ();
269
270
270
271
#pragma mark normal (non-ASTScope-based) lookup declarations
271
272
@@ -425,8 +426,7 @@ void UnqualifiedLookupFactory::fillInLookup() {
425
426
if (lookForAModuleWithTheGivenName (DC))
426
427
return ;
427
428
// Make sure we've recorded the inner-result-boundary.
428
- (void )isFinishedWithLookupNowThatIsAboutToLookForOuterResults (
429
- /* noMoreOuterResults=*/ true );
429
+ setIndexOfFirstOuterResultIfNotSetAlready ();
430
430
}
431
431
432
432
bool UnqualifiedLookupFactory::shouldUseASTScopeLookup () const {
@@ -1062,16 +1062,15 @@ bool UnqualifiedLookupFactory::addNamesKnownToDebugClient(DeclContext *dc) {
1062
1062
if (Name.isSimpleName () && DebugClient)
1063
1063
DebugClient->lookupAdditions (Name.getBaseName (), dc, Loc,
1064
1064
isOriginallyTypeLookup, Results);
1065
-
1065
+ setIndexOfFirstOuterResultIfNotSetAlready ();
1066
1066
// If we've found something, we're done.
1067
- return isFinishedWithLookupNowThatIsAboutToLookForOuterResults (
1068
- /* noMoreOuterResults=*/ true );
1067
+ return !Results.empty ();
1069
1068
}
1070
1069
1071
1070
bool UnqualifiedLookupFactory::addUnavailableInnerResults () {
1072
1071
Results = std::move (UnavailableInnerResults);
1073
- return isFinishedWithLookupNowThatIsAboutToLookForOuterResults (
1074
- /* noMoreOuterResults= */ true );
1072
+ setIndexOfFirstOuterResultIfNotSetAlready ();
1073
+ return !Results. empty ( );
1075
1074
}
1076
1075
1077
1076
bool UnqualifiedLookupFactory::lookForAModuleWithTheGivenName (
@@ -1083,8 +1082,8 @@ bool UnqualifiedLookupFactory::lookForAModuleWithTheGivenName(
1083
1082
// Look for a module with the given name.
1084
1083
if (Name.isSimpleName (M.getName ())) {
1085
1084
Results.push_back (LookupResultEntry (&M));
1086
- return isFinishedWithLookupNowThatIsAboutToLookForOuterResults (
1087
- /* noMoreOuterResults= */ true ) ;
1085
+ setIndexOfFirstOuterResultIfNotSetAlready ();
1086
+ return true ;
1088
1087
}
1089
1088
ModuleDecl *desiredModule = Ctx.getLoadedModule (Name.getBaseIdentifier ());
1090
1089
if (!desiredModule && Name == Ctx.TheBuiltinModule ->getName ())
@@ -1115,18 +1114,18 @@ NLOptions UnqualifiedLookupFactory::computeBaseNLOptions(
1115
1114
baseNLOptions |= NL_IgnoreAccessControl;
1116
1115
return baseNLOptions;
1117
1116
}
1118
- // TODO: elim flag?
1119
- // TODO: fold this into return None?
1117
+
1120
1118
bool UnqualifiedLookupFactory::
1121
- isFinishedWithLookupNowThatIsAboutToLookForOuterResults (
1122
- bool noMoreOuterResults) {
1123
- if (Results.empty ())
1124
- return false ;
1119
+ isFinishedWithLookupNowThatIsAboutToLookForOuterResults () {
1120
+ setIndexOfFirstOuterResultIfNotSetAlready ();
1121
+
1122
+ return !Results.empty () && !options.contains (Flags::IncludeOuterResults);
1123
+ }
1125
1124
1125
+ void UnqualifiedLookupFactory::setIndexOfFirstOuterResultIfNotSetAlready () {
1126
+ // OK to call (NOOP) if there are more inner results and Results is empty
1126
1127
if (IndexOfFirstOuterResult == 0 )
1127
1128
IndexOfFirstOuterResult = Results.size ();
1128
-
1129
- return !options.contains (Flags::IncludeOuterResults) || noMoreOuterResults;
1130
1129
}
1131
1130
1132
1131
bool UnqualifiedLookupFactory::resolveIsCascadingUse (
0 commit comments