Skip to content

Commit 9e18563

Browse files
committed
[Sema] Support -testable-import-module to load transitive non-public dependencies
When using the -testable-import-module argument to insert a testable import, there's no ImportDecl on which to show the diagnostics when loading transitive dependencies. Clean up the logic to still load dependencies in such a case.
1 parent f7f69c6 commit 9e18563

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

lib/Sema/ImportResolution.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,11 @@ void ImportResolver::bindImport(UnboundImport &&I) {
326326

327327
// Load more dependencies for testable imports.
328328
if (I.import.options.contains(ImportFlags::Testable)) {
329+
SourceLoc diagLoc;
330+
if (ID) diagLoc = ID.get()->getStartLoc();
331+
329332
for (auto file: M->getFiles())
330-
file->loadDependenciesForTestable(ID.get()->getStartLoc());
333+
file->loadDependenciesForTestable(diagLoc);
331334
}
332335

333336
auto topLevelModule = I.getTopLevelModule(M, SF);

lib/Serialization/SerializedModuleLoader.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,10 +1479,9 @@ void SerializedASTFile::loadDependenciesForTestable(SourceLoc diagLoc) const {
14791479
File.loadDependenciesForFileContext(this, diagLoc, /*forTestable=*/true);
14801480

14811481
if (status != serialization::Status::Valid) {
1482-
if (diagLoc)
1483-
serialization::diagnoseSerializedASTLoadFailureTransitive(
1484-
getASTContext(), diagLoc, status, &File,
1485-
getParentModule()->getName(), /*forTestable*/true);
1482+
serialization::diagnoseSerializedASTLoadFailureTransitive(
1483+
getASTContext(), diagLoc, status, &File,
1484+
getParentModule()->getName(), /*forTestable*/true);
14861485
}
14871486
}
14881487

0 commit comments

Comments
 (0)