Add missing access path filters for DerivedFileUnit.

I can't see this ever actually being an issue, but if someone performs a
scoped import on another module, and that module synthesizes a derived
declaration, further lookups shouldn't find that declaration if the name
doesn't match the import scope.

Swift SVN r14487
This commit is contained in:
Jordan Rose
2014-02-27 23:46:05 +00:00
parent e02c02b403
commit 7ac2c1de2f

View File

@@ -317,6 +317,13 @@ void DerivedFileUnit::lookupValue(Module::AccessPathTy accessPath,
Identifier name,
NLKind lookupKind,
SmallVectorImpl<ValueDecl*> &result) const {
assert(accessPath.size() <= 1 && "can only refer to top-level decls");
// If this import is specific to some named type or decl ("import Swift.int")
// then filter out any lookups that don't match.
if (accessPath.size() == 1 && accessPath.front().first != Name)
return;
if (name == DerivedDecl->getName())
result.push_back(DerivedDecl);
}
@@ -324,6 +331,14 @@ void DerivedFileUnit::lookupValue(Module::AccessPathTy accessPath,
void DerivedFileUnit::lookupVisibleDecls(Module::AccessPathTy accessPath,
VisibleDeclConsumer &consumer,
NLKind lookupKind) const {
assert(accessPath.size() <= 1 && "can only refer to top-level decls");
// If this import is specific to some named type or decl ("import Swift.int")
// then filter out any lookups that don't match.
if (accessPath.size() == 1 &&
accessPath.front().first != DerivedDecl->getName())
return;
consumer.foundDecl(DerivedDecl, DeclVisibilityKind::VisibleAtTopLevel);
}