[NFC] Clarify semantics of getImportedModules.

The lack of clarity manifested as unexpected behavior when using
getImportedModules to create the module import graph. The new behavior
makes SPI-ness and Shadowing-ness behave similarly in terms of
filtering. We also check if a filter is well-formed to avoid
accidental empty import lists.
This commit is contained in:
Varun Gandhi
2020-09-23 10:43:57 -07:00
parent d3369f7711
commit 4b5d885114
6 changed files with 57 additions and 7 deletions

View File

@@ -175,6 +175,7 @@ ImportSet &ImportCache::getImportSet(const DeclContext *dc) {
ModuleDecl::ImportedModule{ImportPath::Access(), mod});
if (file) {
// Should include both SPI & non-SPI.
file->getImportedModules(imports,
{ModuleDecl::ImportFilterKind::Default,
ModuleDecl::ImportFilterKind::ImplementationOnly,
@@ -260,6 +261,7 @@ ImportCache::getAllAccessPathsNotShadowedBy(const ModuleDecl *mod,
ModuleDecl::ImportedModule{ImportPath::Access(), currentMod});
if (auto *file = dyn_cast<FileUnit>(dc)) {
// Should include both SPI & non-SPI
file->getImportedModules(stack,
{ModuleDecl::ImportFilterKind::Default,
ModuleDecl::ImportFilterKind::ImplementationOnly,