@@ -261,7 +261,10 @@ class UnqualifiedLookupFactory {
261
261
// / results yet?
262
262
bool isLookupDoneWithoutIncludingOuterResults () const ;
263
263
264
- void setIndexOfFirstOuterResultIfNotSetAlready ();
264
+ // / Every time lookup finishes searching a scope, call me
265
+ // / to record the dividing line between results from first fruitful scope and
266
+ // / the result.
267
+ void recordCompletionOfAScope ();
265
268
266
269
#pragma mark normal (non-ASTScope-based) lookup declarations
267
270
@@ -414,10 +417,10 @@ void UnqualifiedLookupFactory::fillInLookup() {
414
417
// TODO: Does the debugger client care about compound names?
415
418
if (Name.isSimpleName () && DebugClient &&
416
419
DebugClient->lookupOverrides (Name.getBaseName (), DC, Loc,
420
+ recordDependencyOnTopLevelName (DC, Name, isCascadingUse);
417
421
isOriginallyTypeLookup, Results))
418
422
return ;
419
423
420
- recordDependencyOnTopLevelName (DC, Name, isCascadingUse);
421
424
addPrivateImports (DC);
422
425
if (addNamesKnownToDebugClient (DC))
423
426
return ;
@@ -429,7 +432,7 @@ void UnqualifiedLookupFactory::fillInLookup() {
429
432
if (lookForAModuleWithTheGivenName (DC))
430
433
return ;
431
434
// Make sure we've recorded the inner-result-boundary.
432
- setIndexOfFirstOuterResultIfNotSetAlready (); // DMU elim?
435
+ recordCompletionOfAScope (); // DMU elim?
433
436
}
434
437
435
438
bool UnqualifiedLookupFactory::shouldUseASTScopeLookup () const {
@@ -511,7 +514,7 @@ UnqualifiedLookupFactory::lookInScopeForASTScopeLookup(
511
514
Consumer.foundDecl (local, getLocalDeclVisibilityKind (currentScope));
512
515
}
513
516
514
- setIndexOfFirstOuterResultIfNotSetAlready ();
517
+ recordCompletionOfAScope ();
515
518
// If we found anything, we're done.
516
519
if (isLookupDoneWithoutIncludingOuterResults ())
517
520
return None;
@@ -641,7 +644,7 @@ UnqualifiedLookupFactory::lookIntoDeclarationContextForASTScopeLookup(
641
644
} else {
642
645
filterForDiscriminator (Results, DebugClient);
643
646
644
- setIndexOfFirstOuterResultIfNotSetAlready ();
647
+ recordCompletionOfAScope ();
645
648
if (isLookupDoneWithoutIncludingOuterResults ())
646
649
return None;
647
650
}
@@ -740,7 +743,7 @@ UnqualifiedLookupFactory::lookupInPatternBindingInitializer(
740
743
// instance member lookup.
741
744
if (auto *selfParam = PBI->getImplicitSelfDecl ()) {
742
745
Consumer.foundDecl (selfParam, DeclVisibilityKind::FunctionParameter);
743
- setIndexOfFirstOuterResultIfNotSetAlready ();
746
+ recordCompletionOfAScope ();
744
747
if (isLookupDoneWithoutIncludingOuterResults ())
745
748
return None;
746
749
DeclContext *const parent = PBI->getParent ();
@@ -789,15 +792,15 @@ UnqualifiedLookupFactory::lookupInFunctionDecl(AbstractFunctionDecl *AFD,
789
792
790
793
namelookup::FindLocalVal localVal (SM, Loc, Consumer);
791
794
localVal.visit (AFD->getBody ());
792
-
793
- setIndexOfFirstOuterResultIfNotSetAlready ();
795
+
796
+ recordCompletionOfAScope ();
794
797
if (isLookupDoneWithoutIncludingOuterResults ())
795
798
return None;
796
799
797
800
if (auto *P = AFD->getImplicitSelfDecl ())
798
801
localVal.checkValueDecl (P, DeclVisibilityKind::FunctionParameter);
799
802
localVal.checkParameterList (AFD->getParameters ());
800
- setIndexOfFirstOuterResultIfNotSetAlready ();
803
+ recordCompletionOfAScope ();
801
804
if (isLookupDoneWithoutIncludingOuterResults ())
802
805
return None;
803
806
}
@@ -811,7 +814,7 @@ UnqualifiedLookupFactory::lookupInFunctionDecl(AbstractFunctionDecl *AFD,
811
814
812
815
// Look in the generic parameters after checking our local declaration.
813
816
addGenericParametersForFunction (AFD);
814
- setIndexOfFirstOuterResultIfNotSetAlready ();
817
+ recordCompletionOfAScope ();
815
818
if (isLookupDoneWithoutIncludingOuterResults ())
816
819
return None;
817
820
@@ -849,12 +852,12 @@ UnqualifiedLookupFactory::lookupInClosure(AbstractClosureExpr *ACE,
849
852
namelookup::FindLocalVal localVal (SM, Loc, Consumer);
850
853
if (auto body = CE->getBody ())
851
854
localVal.visit (body);
852
- setIndexOfFirstOuterResultIfNotSetAlready ();
855
+ recordCompletionOfAScope ();
853
856
if (isLookupDoneWithoutIncludingOuterResults ())
854
857
return None;
855
858
if (auto params = CE->getParameters ())
856
859
localVal.checkParameterList (params);
857
- setIndexOfFirstOuterResultIfNotSetAlready ();
860
+ recordCompletionOfAScope ();
858
861
if (isLookupDoneWithoutIncludingOuterResults ())
859
862
return None;
860
863
}
@@ -939,7 +942,7 @@ bool UnqualifiedLookupFactory::addGenericParametersHereAndInEnclosingScopes(
939
942
namelookup::FindLocalVal localVal (SM, Loc, Consumer);
940
943
localVal.checkGenericParams (dcGenericParams);
941
944
942
- setIndexOfFirstOuterResultIfNotSetAlready ();
945
+ recordCompletionOfAScope ();
943
946
if (isLookupDoneWithoutIncludingOuterResults ())
944
947
return true ;
945
948
}
@@ -967,7 +970,7 @@ bool UnqualifiedLookupFactory::addLocalVariableResults(DeclContext *dc) {
967
970
// local types.
968
971
namelookup::FindLocalVal localVal (SM, Loc, Consumer);
969
972
localVal.checkSourceFile (*SF);
970
- setIndexOfFirstOuterResultIfNotSetAlready ();
973
+ recordCompletionOfAScope ();
971
974
if (isLookupDoneWithoutIncludingOuterResults ())
972
975
return true ;
973
976
}
@@ -1012,7 +1015,7 @@ bool UnqualifiedLookupFactory::handleUnavailableInnerResults(
1012
1015
}
1013
1016
filterForDiscriminator (Results, DebugClient);
1014
1017
1015
- setIndexOfFirstOuterResultIfNotSetAlready ();
1018
+ recordCompletionOfAScope ();
1016
1019
return isLookupDoneWithoutIncludingOuterResults ();
1017
1020
}
1018
1021
@@ -1052,14 +1055,14 @@ bool UnqualifiedLookupFactory::addNamesKnownToDebugClient(DeclContext *dc) {
1052
1055
if (Name.isSimpleName () && DebugClient)
1053
1056
DebugClient->lookupAdditions (Name.getBaseName (), dc, Loc,
1054
1057
isOriginallyTypeLookup, Results);
1055
- setIndexOfFirstOuterResultIfNotSetAlready ();
1058
+ recordCompletionOfAScope ();
1056
1059
// If we've found something, we're done.
1057
1060
return !Results.empty ();
1058
1061
}
1059
1062
1060
1063
bool UnqualifiedLookupFactory::addUnavailableInnerResults () {
1061
1064
Results = std::move (UnavailableInnerResults);
1062
- setIndexOfFirstOuterResultIfNotSetAlready ();
1065
+ recordCompletionOfAScope ();
1063
1066
return !Results.empty ();
1064
1067
}
1065
1068
@@ -1072,7 +1075,7 @@ bool UnqualifiedLookupFactory::lookForAModuleWithTheGivenName(
1072
1075
// Look for a module with the given name.
1073
1076
if (Name.isSimpleName (M.getName ())) {
1074
1077
Results.push_back (LookupResultEntry (&M));
1075
- setIndexOfFirstOuterResultIfNotSetAlready ();
1078
+ recordCompletionOfAScope ();
1076
1079
return true ;
1077
1080
}
1078
1081
ModuleDecl *desiredModule = Ctx.getLoadedModule (Name.getBaseIdentifier ());
@@ -1110,7 +1113,7 @@ bool UnqualifiedLookupFactory::isLookupDoneWithoutIncludingOuterResults()
1110
1113
return !Results.empty () && !options.contains (Flags::IncludeOuterResults);
1111
1114
}
1112
1115
1113
- void UnqualifiedLookupFactory::setIndexOfFirstOuterResultIfNotSetAlready () {
1116
+ void UnqualifiedLookupFactory::recordCompletionOfAScope () {
1114
1117
// OK to call (NOOP) if there are more inner results and Results is empty
1115
1118
if (IndexOfFirstOuterResult == 0 )
1116
1119
IndexOfFirstOuterResult = Results.size ();
0 commit comments