Move access-path filtering into ModuleNameLookup (out of lookupValue) (#27097)

Removes duplicated logic from the implementations of
FileUnit::lookupValue, and simplifies the interface to
ModuleDecl::lookupValue, where everyone was passing an empty
(non-filtering) access path anyway /except/ during actual lookup from
source code. No functionality change.
This commit is contained in:
Jordan Rose
2019-09-10 09:13:20 -07:00
committed by GitHub
parent 04ae94fbf3
commit d4ac04d25e
21 changed files with 52 additions and 83 deletions

View File

@@ -654,7 +654,7 @@ void ASTContext::lookupInSwiftModule(
// Find all of the declarations with this name in the Swift module.
auto identifier = getIdentifier(name);
M->lookupValue({ }, identifier, NLKind::UnqualifiedLookup, results);
M->lookupValue(identifier, NLKind::UnqualifiedLookup, results);
}
FuncDecl *ASTContext::getPlusFunctionOnRangeReplaceableCollection() const {
@@ -832,7 +832,7 @@ StructDecl *ASTContext::getObjCBoolDecl() const {
SmallVector<ValueDecl *, 1> results;
auto *Context = const_cast<ASTContext *>(this);
if (ModuleDecl *M = Context->getModuleByName(Id_ObjectiveC.str())) {
M->lookupValue({ }, getIdentifier("ObjCBool"), NLKind::UnqualifiedLookup,
M->lookupValue(getIdentifier("ObjCBool"), NLKind::UnqualifiedLookup,
results);
for (auto result : results) {
if (auto structDecl = dyn_cast<StructDecl>(result)) {
@@ -899,7 +899,7 @@ ProtocolDecl *ASTContext::getProtocol(KnownProtocolKind kind) const {
if (!M)
return nullptr;
M->lookupValue({ }, getIdentifier(getProtocolName(kind)),
M->lookupValue(getIdentifier(getProtocolName(kind)),
NLKind::UnqualifiedLookup, results);
for (auto result : results) {
@@ -3959,7 +3959,7 @@ static NominalTypeDecl *findUnderlyingTypeInModule(ASTContext &ctx,
ModuleDecl *module) {
// Find all of the declarations with this name in the Swift module.
SmallVector<ValueDecl *, 1> results;
module->lookupValue({ }, name, NLKind::UnqualifiedLookup, results);
module->lookupValue(name, NLKind::UnqualifiedLookup, results);
for (auto result : results) {
if (auto nominal = dyn_cast<NominalTypeDecl>(result))
return nominal;