Skip to content

Commit e136834

Browse files
authored
Merge pull request swiftlang#27016 from slavapestov/review-feedback-for-module-lookup
Sema: Late code review feedback from @jrose-apple
2 parents 8280358 + 08e5045 commit e136834

File tree

2 files changed

+5
-27
lines changed

2 files changed

+5
-27
lines changed

lib/AST/ModuleNameLookup.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,8 @@ void ModuleNameLookup<LookupStrategy>::lookupInModule(
153153
resolutionKind == ResolutionKind::Overloadable) {
154154
// If we only found top-level functions, keep looking, since we may
155155
// find additional overloads.
156-
if (std::find_if(decls.begin() + initialCount, decls.end(),
157-
[](ValueDecl *VD) { return !isa<FuncDecl>(VD); })
158-
== decls.end())
156+
if (std::all_of(decls.begin() + initialCount, decls.end(),
157+
[](ValueDecl *VD) { return isa<FuncDecl>(VD); }))
159158
canReturnEarly = false;
160159
}
161160

lib/Sema/TypeCheckAttr.cpp

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1608,7 +1608,8 @@ void AttributeChecker::checkApplicationMainAttribute(DeclAttribute *attr,
16081608

16091609
// @XXApplicationMain classes must conform to the XXApplicationDelegate
16101610
// protocol.
1611-
auto &C = D->getASTContext();
1611+
auto *SF = cast<SourceFile>(CD->getModuleScopeContext());
1612+
auto &C = SF->getASTContext();
16121613

16131614
auto KitModule = C.getLoadedModule(Id_Kit);
16141615
ProtocolDecl *ApplicationDelegateProto = nullptr;
@@ -1617,7 +1618,7 @@ void AttributeChecker::checkApplicationMainAttribute(DeclAttribute *attr,
16171618
namelookup::lookupInModule(KitModule, Id_ApplicationDelegate,
16181619
decls, NLKind::QualifiedLookup,
16191620
namelookup::ResolutionKind::TypesOnly,
1620-
KitModule);
1621+
SF);
16211622
if (decls.size() == 1)
16221623
ApplicationDelegateProto = dyn_cast<ProtocolDecl>(decls[0]);
16231624
}
@@ -1637,30 +1638,8 @@ void AttributeChecker::checkApplicationMainAttribute(DeclAttribute *attr,
16371638

16381639
// Register the class as the main class in the module. If there are multiples
16391640
// they will be diagnosed.
1640-
auto *SF = cast<SourceFile>(CD->getModuleScopeContext());
16411641
if (SF->registerMainClass(CD, attr->getLocation()))
16421642
attr->setInvalid();
1643-
1644-
// Check that we have the needed symbols in the frameworks.
1645-
auto lookupOptions = defaultUnqualifiedLookupOptions;
1646-
lookupOptions |= NameLookupFlags::KnownPrivate;
1647-
auto lookupMain = TC.lookupUnqualified(KitModule, Id_ApplicationMain,
1648-
SourceLoc(), lookupOptions);
1649-
1650-
for (const auto &result : lookupMain) {
1651-
TC.validateDecl(result.getValueDecl());
1652-
}
1653-
auto Foundation = TC.Context.getLoadedModule(C.Id_Foundation);
1654-
if (Foundation) {
1655-
auto lookupString = TC.lookupUnqualified(
1656-
Foundation,
1657-
C.getIdentifier("NSStringFromClass"),
1658-
SourceLoc(),
1659-
lookupOptions);
1660-
for (const auto &result : lookupString) {
1661-
TC.validateDecl(result.getValueDecl());
1662-
}
1663-
}
16641643
}
16651644

16661645
void AttributeChecker::visitNSApplicationMainAttr(NSApplicationMainAttr *attr) {

0 commit comments

Comments
 (0)