Move lookupQualified from Module to DeclContext.

Qualified lookup depends not only on the current module but actually the
current file, since imports are file-scoped by default. Currently this only
affects lookup into other modules (e.g. "Foundation.NSString"), but this
could also be used for extension filtering.

This breaks one name resolution test, but the refactoring in the next
commit changes everything anyway and will restore the test.

Swift SVN r10831
This commit is contained in:
Jordan Rose
2013-12-05 01:51:07 +00:00
parent eede5ec4f9
commit d0d661164d
8 changed files with 88 additions and 50 deletions

View File

@@ -1114,6 +1114,20 @@ void Module::forAllVisibleModules(Optional<AccessPathTy> thisPath,
forAllImportedModules<true>(this, thisPath, fn);
}
void
FileUnit::forAllVisibleModules(std::function<bool(Module::ImportedModule)> fn) {
getParentModule()->forAllVisibleModules(Module::AccessPathTy(), fn);
if (auto SF = dyn_cast<SourceFile>(this)) {
// Handle privately visible modules as well.
for (auto importPair : SF->getImports()) {
if (!importPair.second)
importPair.first.second->forAllVisibleModules(importPair.first.first,
fn);
}
}
}
void Module::collectLinkLibraries(LinkLibraryCallback callback) {
forAllImportedModules<false>(this, AccessPathTy(),
[=](ImportedModule import) -> bool {