Treat "lookup into immediately imported modules" as a special case

Features like `@testable import` change the results produced by name
lookup in the source file with the testable import. What they
/shouldn't/ do is change the results of lookup into the same module
from elsewhere in the import graph...and neither should cached results
from lookup elsewhere in the import graph affect the lookups from the
source file. Encode this difference in the cache used during
module-level name lookup to fix testable imports like this.

(The test case here looks a little contrived because of '@_exported',
but that's how imports are treated in Clang modules and with bridging
headers, so it is in fact a realistic scenario.)

rdar://problem/48890959
This commit is contained in:
Jordan Rose
2019-03-22 19:57:19 -07:00
parent 734b2cf986
commit 123399db2b
6 changed files with 37 additions and 14 deletions

View File

@@ -250,7 +250,7 @@ void NameBinder::addImport(
}
}
if (SF.getParentModule()->isResilient() &&
if (SF.getParentModule()->isResilient() && topLevelModule &&
!topLevelModule->isResilient() &&
!topLevelModule->isNonSwiftModule() &&
!ID->getAttrs().hasAttribute<ImplementationOnlyAttr>()) {