[IDE][AST] Handle frameworks with traditional overlays where the underlying module declares cross imports in sourcekit.

We weren't handling this case, so their generated interfaces / doc info
wouldn't include symbols from the cross-import overlays, and we wouldn't
map the underscored cross-import overlay name back to the declaring
framework's name in cusor-info, completion results or when indexing.

Resolves rdar://problem/62138551
This commit is contained in:
Nathan Hawes
2020-04-22 19:35:33 -07:00
parent 82d73b531b
commit b7ac8f87b1
15 changed files with 841 additions and 30 deletions

View File

@@ -429,6 +429,9 @@ getDeclsFromCrossImportOverlay(ModuleDecl *Overlay, ModuleDecl *Declaring,
auto NewEnd = std::partition(Decls.begin(), Decls.end(), [&](Decl *D) {
if (auto *ID = dyn_cast<ImportDecl>(D)) {
ModuleDecl *Imported = ID->getModule();
if (!Imported)
return true;
// Ignore imports of the underlying module, or any cross-import
// that would map back to it.
if (Imported == Declaring || Imported->isCrossImportOverlayOf(Declaring))
@@ -497,8 +500,13 @@ static void printCrossImportOverlays(ModuleDecl *Declaring, ASTContext &Ctx,
continue;
Bystanders.clear();
Overlay->getRequiredBystandersIfCrossImportOverlay(Declaring, Bystanders);
assert(!Bystanders.empty() && "Overlay with no bystanders?");
auto BystandersValid =
Overlay->getRequiredBystandersIfCrossImportOverlay(Declaring, Bystanders);
// Ignore badly formed overlays that don't import their declaring module.
if (!BystandersValid)
continue;
std::sort(Bystanders.begin(), Bystanders.end(),
[](Identifier LHS, Identifier RHS) {
return LHS.str() < RHS.str();