Skip to content

Commit d5983da

Browse files
author
David Ungar
committed
Minor prettying.
1 parent 3c32a41 commit d5983da

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

lib/AST/UnqualifiedLookup.cpp

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -273,15 +273,15 @@ class UnqualifiedLookupFactory {
273273
/// the result.
274274
void recordCompletionOfAScope();
275275

276-
template <typename Fn> void runIfNotDoneYet(Fn fn) {
276+
template <typename Fn> void ifNotDoneYet(Fn fn) {
277277
recordCompletionOfAScope();
278278
if (!isFirstResultEnough())
279279
fn();
280280
}
281281

282-
template <typename Fn1, typename Fn2> void runIfNotDoneYet(Fn1 fn1, Fn2 fn2) {
283-
runIfNotDoneYet(fn1);
284-
runIfNotDoneYet(fn2);
282+
template <typename Fn1, typename Fn2> void ifNotDoneYet(Fn1 fn1, Fn2 fn2) {
283+
ifNotDoneYet(fn1);
284+
ifNotDoneYet(fn2);
285285
}
286286

287287
#pragma mark normal (non-ASTScope-based) lookup declarations
@@ -520,23 +520,22 @@ void UnqualifiedLookupFactory::lookInScopeForASTScopeLookup(
520520
for (auto local : localBindings) {
521521
Consumer.foundDecl(local, getLocalDeclVisibilityKind(state.scope));
522522
}
523-
const bool inBody =
524-
state.scope->getKind() == ASTScopeKind::AbstractFunctionBody &&
525-
state.scope->getAbstractFunctionDecl()->getDeclContext()->isTypeContext();
526-
527-
// When we are in the body of a method, get the 'self' declaration.
528-
runIfNotDoneYet([&] {
523+
ifNotDoneYet([&] {
524+
// When we are in the body of a method, get the 'self' declaration.
525+
const bool inBody =
526+
state.scope->getKind() == ASTScopeKind::AbstractFunctionBody &&
527+
state.scope->getAbstractFunctionDecl()
528+
->getDeclContext()
529+
->isTypeContext();
529530
if (inBody)
530531
lookInScopeForASTScopeLookup(
531532
state.withSelfDC(state.scope->getAbstractFunctionDecl())
532533
.withParentScope());
534+
// If there is a declaration context associated with this scope, we might
535+
// want to look in it.
536+
else
537+
lookIntoDeclarationContextForASTScopeLookup(state);
533538
});
534-
if (inBody)
535-
return;
536-
537-
// If there is a declaration context associated with this scope, we might
538-
// want to look in it.
539-
runIfNotDoneYet([&] { lookIntoDeclarationContextForASTScopeLookup(state); });
540539
}
541540

542541
void UnqualifiedLookupFactory::lookIntoDeclarationContextForASTScopeLookup(
@@ -620,7 +619,7 @@ void UnqualifiedLookupFactory::lookIntoDeclarationContextForASTScopeLookup(
620619
defaultNextState.selfDC ? defaultNextState.selfDC : scopeDC, scopeDC),
621620
isCascadingUseResult, baseNLOptions, scopeDC);
622621
// Forget the 'self' declaration.
623-
runIfNotDoneYet([&] {
622+
ifNotDoneYet([&] {
624623
lookInScopeForASTScopeLookup(defaultNextState.withSelfDC(nullptr));
625624
});
626625
}
@@ -675,7 +674,7 @@ void UnqualifiedLookupFactory::finishLookingInContext(
675674
if (addGenericParameters == AddGenericParameters::Yes)
676675
addGenericParametersHereAndInEnclosingScopes(lookupContextForThisContext);
677676

678-
runIfNotDoneYet(
677+
ifNotDoneYet(
679678
[&] {
680679
if (resultFinderForSelfsConformances)
681680
findResultsAndSaveUnavailables(
@@ -702,8 +701,9 @@ void UnqualifiedLookupFactory::lookupInModuleScopeContext(
702701
DeclContext *dc, Optional<bool> isCascadingUse) {
703702
if (auto SF = dyn_cast<SourceFile>(dc))
704703
lookForLocalVariablesIn(SF);
705-
runIfNotDoneYet([&] {
706-
// TODO: why isn't the following line unconditional?
704+
ifNotDoneYet([&] {
705+
// TODO: figure out why this line is here, not unconditional, or after
706+
// lookupNonLocals.
707707
recordDependencyOnTopLevelName(dc, Name, isCascadingUse.getValueOr(true));
708708
lookupNonlocalsInModuleScopeContext(dc);
709709
});
@@ -728,7 +728,7 @@ void UnqualifiedLookupFactory::lookupNamesIntroducedByPatternBindingInitializer(
728728
PatternBindingInitializer *PBI, ParamDecl *selfParam,
729729
Optional<bool> isCascadingUse) {
730730
Consumer.foundDecl(selfParam, DeclVisibilityKind::FunctionParameter);
731-
runIfNotDoneYet([&] {
731+
ifNotDoneYet([&] {
732732
DeclContext *const patternContainer = PBI->getParent();
733733
// clang-format off
734734
finishLookingInContext(
@@ -791,7 +791,7 @@ void UnqualifiedLookupFactory::lookupNamesIntroducedByFunctionDecl(
791791
void UnqualifiedLookupFactory::lookupNamesIntroducedByMemberFunction(
792792
AbstractFunctionDecl *AFD, bool isCascadingUse) {
793793
lookForLocalVariablesIn(AFD, isCascadingUse);
794-
runIfNotDoneYet(
794+
ifNotDoneYet(
795795
[&] {
796796
// If we're inside a function context, we're about to move to
797797
// the parent DC, so we have to check the function's generic
@@ -824,7 +824,7 @@ void UnqualifiedLookupFactory::lookupNamesIntroducedByMemberFunction(
824824
void UnqualifiedLookupFactory::lookupNamesIntroducedByPureFunction(
825825
AbstractFunctionDecl *AFD, bool isCascadingUse) {
826826
lookForLocalVariablesIn(AFD, isCascadingUse);
827-
runIfNotDoneYet([&] {
827+
ifNotDoneYet([&] {
828828
// clang-format off
829829
finishLookingInContext(
830830
AddGenericParameters::Yes,
@@ -839,7 +839,7 @@ void UnqualifiedLookupFactory::lookupNamesIntroducedByClosure(
839839
AbstractClosureExpr *ACE, Optional<bool> isCascadingUse) {
840840
if (auto *CE = dyn_cast<ClosureExpr>(ACE))
841841
lookForLocalVariablesIn(CE);
842-
runIfNotDoneYet([&] {
842+
ifNotDoneYet([&] {
843843
// clang-format off
844844
finishLookingInContext(
845845
AddGenericParameters::Yes,
@@ -905,7 +905,7 @@ void UnqualifiedLookupFactory::lookForLocalVariablesIn(
905905
namelookup::FindLocalVal localVal(SM, Loc, Consumer);
906906
localVal.visit(AFD->getBody());
907907

908-
runIfNotDoneYet([&] {
908+
ifNotDoneYet([&] {
909909
if (auto *P = AFD->getImplicitSelfDecl())
910910
localVal.checkValueDecl(P, DeclVisibilityKind::FunctionParameter);
911911
localVal.checkParameterList(AFD->getParameters());
@@ -920,7 +920,7 @@ void UnqualifiedLookupFactory::lookForLocalVariablesIn(ClosureExpr *CE) {
920920
namelookup::FindLocalVal localVal(SM, Loc, Consumer);
921921
if (auto body = CE->getBody())
922922
localVal.visit(body);
923-
runIfNotDoneYet([&] {
923+
ifNotDoneYet([&] {
924924
if (auto params = CE->getParameters())
925925
localVal.checkParameterList(params);
926926
});
@@ -970,7 +970,7 @@ void UnqualifiedLookupFactory::addGenericParametersHereAndInEnclosingScopes(
970970
return;
971971
namelookup::FindLocalVal localVal(SM, Loc, Consumer);
972972
localVal.checkGenericParams(dcGenericParams);
973-
runIfNotDoneYet([&] {
973+
ifNotDoneYet([&] {
974974
addGenericParametersHereAndInEnclosingScopes(
975975
dcGenericParams->getOuterParameters());
976976
});

0 commit comments

Comments
 (0)