[Sema] @_exported imports export @_spi decls too

Enable transitive imports of all SPI groups through @_exported imports.
This brings to SPI the same behavior that we have for API.

```
// Module A
@_spi(S) public func foo() {}

// Module B
@_exported import A

// Module C
@_spi(S) import B

foo() // SPI imported through the reexport of A from B
```

rdar://101566534
This commit is contained in:
Alexis Laferrière
2022-11-08 15:02:11 -08:00
parent 3ca1de0a0f
commit c0abde01a2
3 changed files with 154 additions and 2 deletions

View File

@@ -1488,11 +1488,13 @@ void SerializedASTFile::lookupImportedSPIGroups(
const ModuleDecl *importedModule,
llvm::SmallSetVector<Identifier, 4> &spiGroups) const {
auto M = getParentModule();
auto &imports = M->getASTContext().getImportCache();
for (auto &dep : File.Dependencies) {
if (!dep.Import.hasValue())
continue;
if (dep.Import->importedModule == importedModule) {
if (dep.Import->importedModule == importedModule ||
imports.isImportedBy(importedModule, dep.Import->importedModule)) {
spiGroups.insert(dep.spiGroups.begin(), dep.spiGroups.end());
}
}