mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Add the notion of "re-exported" modules, and use that where it makes sense.
Rather than automatically re-exporting or not re-exporting every import in a TranslationUnit, we'll eventually want to control which imports are local (most of them) and which imports are shared with eventual module loaders. It's probably not worth implementing this for TranslationUnit, but LoadedModule can certainly do something here. Currently, a LoadedModule is even more permissive than a TranslationUnit: all imports are re-exported. We can lock down on this once we have a re-export syntax. Swift SVN r6523
This commit is contained in:
@@ -1272,6 +1272,16 @@ Decl *ModuleFile::getDecl(DeclID DID, Optional<DeclContext *> ForcedContext,
|
||||
getIdentifier(rawAccessPath.front()),
|
||||
NLKind::QualifiedLookup,
|
||||
values);
|
||||
// FIXME: Yuck. The concept of a shadowed module needs to be moved up
|
||||
// higher, and it needs to be clear whether they are always reexported.
|
||||
if (auto loadedModule = dyn_cast<SerializedModule>(baseModule)) {
|
||||
if (loadedModule->File && loadedModule->File->ShadowedModule) {
|
||||
Module *shadowed = loadedModule->File->ShadowedModule;
|
||||
shadowed->lookupValue(Module::AccessPathTy(),
|
||||
getIdentifier(rawAccessPath.front()),
|
||||
NLKind::QualifiedLookup, values);
|
||||
}
|
||||
}
|
||||
rawAccessPath = rawAccessPath.slice(1);
|
||||
|
||||
// Then, follow the chain of nested ValueDecls until we run out of
|
||||
@@ -2123,9 +2133,11 @@ OperatorDecl *ModuleFile::lookupOperator(Identifier name, DeclKind fixity) {
|
||||
return Operators.lookup(OperatorKey(name, getOperatorKind(fixity)));
|
||||
}
|
||||
|
||||
void ModuleFile::getReexportedModules(SmallVectorImpl<Module*> &results) {
|
||||
// FIXME: Generalized re-exports.
|
||||
if (ShadowedModule)
|
||||
results.push_back(ShadowedModule);
|
||||
void ModuleFile::getReexportedModules(
|
||||
SmallVectorImpl<Module::ImportedModule> &results) {
|
||||
// FIXME: Lock down on re-exports.
|
||||
// FIXME: Handle imports with access paths.
|
||||
for (auto &dep : Dependencies)
|
||||
results.push_back({Module::AccessPathTy(), dep.Mod});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user