@@ -262,9 +262,9 @@ class UnqualifiedLookupFactory {
262
262
DeclContext *selfDC,
263
263
DeclContext *wasDC,
264
264
Optional<bool > isCascadingUse);
265
-
266
- // / Return true if done with lookup.
267
- bool isFinishedWithLookupNowThatIsAboutToLookForOuterResults () ;
265
+ // / Can lookup stop searching for results, assuming hasn't looked for outer
266
+ // / results yet?
267
+ bool isLookupDoneWithoutIncludingOuterResults () const ;
268
268
269
269
void setIndexOfFirstOuterResultIfNotSetAlready ();
270
270
@@ -456,10 +456,10 @@ UnqualifiedLookupFactory::astScopeBasedLookup(DeclContext *const startDC,
456
456
currentIsCascadingUse);
457
457
if (!r.hasValue ())
458
458
return None;
459
- const bool isDone = r.getValue ().isDone ;
460
459
selfDC = r.getValue ().selfDC ;
461
460
dc = r.getValue ().dc ;
462
461
currentIsCascadingUse = r.getValue ().isCascadingUse ;
462
+ const bool isDone = r.getValue ().isDone ;
463
463
if (isDone)
464
464
return DCAndIsCascadingUse{dc, currentIsCascadingUse.getValue ()};
465
465
}
@@ -508,8 +508,9 @@ UnqualifiedLookupFactory::lookInScopeForASTScopeLookup(
508
508
Consumer.foundDecl (local, getLocalDeclVisibilityKind (currentScope));
509
509
}
510
510
511
+ setIndexOfFirstOuterResultIfNotSetAlready ();
511
512
// If we found anything, we're done.
512
- if (isFinishedWithLookupNowThatIsAboutToLookForOuterResults ())
513
+ if (isLookupDoneWithoutIncludingOuterResults ())
513
514
return None;
514
515
515
516
// When we are in the body of a method, get the 'self' declaration.
@@ -638,7 +639,8 @@ UnqualifiedLookupFactory::lookIntoDeclarationContextForASTScopeLookup(
638
639
if (DebugClient)
639
640
filterForDiscriminator (Results, DebugClient);
640
641
641
- if (isFinishedWithLookupNowThatIsAboutToLookForOuterResults ())
642
+ setIndexOfFirstOuterResultIfNotSetAlready ();
643
+ if (isLookupDoneWithoutIncludingOuterResults ())
642
644
return None;
643
645
}
644
646
}
@@ -747,7 +749,8 @@ UnqualifiedLookupFactory::lookupInPatternBindingInitializer(
747
749
// instance member lookup.
748
750
if (auto *selfParam = PBI->getImplicitSelfDecl ()) {
749
751
Consumer.foundDecl (selfParam, DeclVisibilityKind::FunctionParameter);
750
- if (isFinishedWithLookupNowThatIsAboutToLookForOuterResults ())
752
+ setIndexOfFirstOuterResultIfNotSetAlready ();
753
+ if (isLookupDoneWithoutIncludingOuterResults ())
751
754
return None;
752
755
DeclContext *const parent = PBI->getParent ();
753
756
// clang-format off
@@ -798,13 +801,15 @@ UnqualifiedLookupFactory::lookupInFunctionDecl(AbstractFunctionDecl *AFD,
798
801
799
802
namelookup::FindLocalVal localVal (SM, Loc, Consumer);
800
803
localVal.visit (AFD->getBody ());
801
- if (isFinishedWithLookupNowThatIsAboutToLookForOuterResults ())
804
+ setIndexOfFirstOuterResultIfNotSetAlready ();
805
+ if (isLookupDoneWithoutIncludingOuterResults ())
802
806
return None;
803
807
804
808
if (auto *P = AFD->getImplicitSelfDecl ())
805
809
localVal.checkValueDecl (P, DeclVisibilityKind::FunctionParameter);
806
810
localVal.checkParameterList (AFD->getParameters ());
807
- if (isFinishedWithLookupNowThatIsAboutToLookForOuterResults ())
811
+ setIndexOfFirstOuterResultIfNotSetAlready ();
812
+ if (isLookupDoneWithoutIncludingOuterResults ())
808
813
return None;
809
814
}
810
815
const bool returnValueForIsCascadingUse =
@@ -818,7 +823,8 @@ UnqualifiedLookupFactory::lookupInFunctionDecl(AbstractFunctionDecl *AFD,
818
823
DeclContext *fnDeclContext = AFD->getDeclContext ();
819
824
DeclContext *fnParent = AFD->getParent ();
820
825
addGenericParametersForFunction (AFD);
821
- if (isFinishedWithLookupNowThatIsAboutToLookForOuterResults ())
826
+ setIndexOfFirstOuterResultIfNotSetAlready ();
827
+ if (isLookupDoneWithoutIncludingOuterResults ())
822
828
return None;
823
829
// clang-format off
824
830
return PerScopeLookupState{
@@ -838,7 +844,8 @@ UnqualifiedLookupFactory::lookupInFunctionDecl(AbstractFunctionDecl *AFD,
838
844
}
839
845
// Look in the generic parameters after checking our local declaration.
840
846
addGenericParametersForFunction (AFD);
841
- if (isFinishedWithLookupNowThatIsAboutToLookForOuterResults ())
847
+ setIndexOfFirstOuterResultIfNotSetAlready ();
848
+ if (isLookupDoneWithoutIncludingOuterResults ())
842
849
return None;
843
850
// clang-format off
844
851
return PerScopeLookupState{
@@ -859,11 +866,13 @@ UnqualifiedLookupFactory::lookupInClosure(AbstractClosureExpr *ACE,
859
866
namelookup::FindLocalVal localVal (SM, Loc, Consumer);
860
867
if (auto body = CE->getBody ())
861
868
localVal.visit (body);
862
- if (isFinishedWithLookupNowThatIsAboutToLookForOuterResults ())
869
+ setIndexOfFirstOuterResultIfNotSetAlready ();
870
+ if (isLookupDoneWithoutIncludingOuterResults ())
863
871
return None;
864
872
if (auto params = CE->getParameters ())
865
873
localVal.checkParameterList (params);
866
- if (isFinishedWithLookupNowThatIsAboutToLookForOuterResults ())
874
+ setIndexOfFirstOuterResultIfNotSetAlready ();
875
+ if (isLookupDoneWithoutIncludingOuterResults ())
867
876
return None;
868
877
}
869
878
}
@@ -950,7 +959,8 @@ bool UnqualifiedLookupFactory::addGenericParametersHereAndInEnclosingScopes(
950
959
namelookup::FindLocalVal localVal (SM, Loc, Consumer);
951
960
localVal.checkGenericParams (dcGenericParams);
952
961
953
- if (isFinishedWithLookupNowThatIsAboutToLookForOuterResults ())
962
+ setIndexOfFirstOuterResultIfNotSetAlready ();
963
+ if (isLookupDoneWithoutIncludingOuterResults ())
954
964
return true ;
955
965
}
956
966
return false ;
@@ -977,7 +987,8 @@ bool UnqualifiedLookupFactory::addLocalVariableResults(DeclContext *dc) {
977
987
// local types.
978
988
namelookup::FindLocalVal localVal (SM, Loc, Consumer);
979
989
localVal.checkSourceFile (*SF);
980
- if (isFinishedWithLookupNowThatIsAboutToLookForOuterResults ())
990
+ setIndexOfFirstOuterResultIfNotSetAlready ();
991
+ if (isLookupDoneWithoutIncludingOuterResults ())
981
992
return true ;
982
993
}
983
994
}
@@ -1022,7 +1033,8 @@ bool UnqualifiedLookupFactory::handleUnavailableInnerResults(
1022
1033
if (DebugClient)
1023
1034
filterForDiscriminator (Results, DebugClient);
1024
1035
1025
- return isFinishedWithLookupNowThatIsAboutToLookForOuterResults ();
1036
+ setIndexOfFirstOuterResultIfNotSetAlready ();
1037
+ return isLookupDoneWithoutIncludingOuterResults ();
1026
1038
}
1027
1039
1028
1040
void UnqualifiedLookupFactory::recordDependencyOnTopLevelName (
@@ -1115,10 +1127,8 @@ NLOptions UnqualifiedLookupFactory::computeBaseNLOptions(
1115
1127
return baseNLOptions;
1116
1128
}
1117
1129
1118
- bool UnqualifiedLookupFactory::
1119
- isFinishedWithLookupNowThatIsAboutToLookForOuterResults () {
1120
- setIndexOfFirstOuterResultIfNotSetAlready ();
1121
-
1130
+ bool UnqualifiedLookupFactory::isLookupDoneWithoutIncludingOuterResults ()
1131
+ const {
1122
1132
return !Results.empty () && !options.contains (Flags::IncludeOuterResults);
1123
1133
}
1124
1134
0 commit comments