mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
When loading a Swift framework module, see if it's also a Clang module.
In a framework containing both Clang headers and a Swift module, the Swift module gets picked up first, but then automatically imports (and re-exports) the Clang module as well. One interesting case here is that it's possible for the Clang side to add categories to a class declared in Swift. In order to support this, the Clang importer can now find extensions for Swift classes marked @objc. (I couldn't think of a way to test this separately; the previous commit was supposed to do that, but worked without this change.) <rdar://problem/16295937> Swift SVN r15084
This commit is contained in:
@@ -803,6 +803,9 @@ bool ModuleFile::associateWithFileContext(FileUnit *file) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Bits.IsFramework)
|
||||
(void)getModule(FileContext->getParentModule()->Name);
|
||||
|
||||
return getStatus() == ModuleStatus::Valid;
|
||||
}
|
||||
|
||||
@@ -870,6 +873,8 @@ void ModuleFile::getImportedModules(
|
||||
SmallVectorImpl<Module::ImportedModule> &results,
|
||||
Module::ImportFilter filter) {
|
||||
PrettyModuleFileDeserialization stackEntry(*this);
|
||||
bool includeShadowedModule =
|
||||
(filter != Module::ImportFilter::Private && Bits.IsFramework);
|
||||
|
||||
for (auto &dep : Dependencies) {
|
||||
if (filter != Module::ImportFilter::All &&
|
||||
@@ -877,7 +882,18 @@ void ModuleFile::getImportedModules(
|
||||
continue;
|
||||
assert(dep.isLoaded());
|
||||
results.push_back(dep.Import);
|
||||
|
||||
// FIXME: Do we want a way to limit re-exports?
|
||||
if (includeShadowedModule && dep.Import.first.empty() &&
|
||||
dep.Import.second == ShadowedModule)
|
||||
includeShadowedModule = false;
|
||||
}
|
||||
|
||||
// Make sure to go through getModule() instead of accessing ShadowedModule
|
||||
// directly, to force loading it.
|
||||
if (includeShadowedModule)
|
||||
if (ShadowedModule)
|
||||
results.push_back({ {}, ShadowedModule });
|
||||
}
|
||||
|
||||
void ModuleFile::getImportDecls(SmallVectorImpl<Decl *> &Results) {
|
||||
|
||||
Reference in New Issue
Block a user