Skip to content

Commit ecfac0b

Browse files
authored
Merge pull request swiftlang#68588 from xymus/get-loaded-optional-deps-5.10
[5.10] Serialization: Ignore missing potentially non-required dependencies when listing imports
2 parents ab9b904 + e1e0ae8 commit ecfac0b

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

lib/Serialization/ModuleFile.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -496,20 +496,20 @@ void ModuleFile::getImportedModules(SmallVectorImpl<ImportedModule> &results,
496496
continue;
497497

498498
} else if (dep.isImplementationOnly()) {
499-
if (!filter.contains(ModuleDecl::ImportFilterKind::ImplementationOnly))
499+
// Pretend we didn't have potentially optional imports if we weren't
500+
// originally asked to load it.
501+
if (!filter.contains(ModuleDecl::ImportFilterKind::ImplementationOnly) ||
502+
!dep.isLoaded())
500503
continue;
501-
if (!dep.isLoaded()) {
502-
// Pretend we didn't have this import if we weren't originally asked to
503-
// load it.
504-
continue;
505-
}
506504

507505
} else if (dep.isInternalOrBelow()) {
508-
if (!filter.contains(ModuleDecl::ImportFilterKind::InternalOrBelow))
506+
if (!filter.contains(ModuleDecl::ImportFilterKind::InternalOrBelow) ||
507+
!dep.isLoaded())
509508
continue;
510509

511510
} else if (dep.isPackageOnly()) {
512-
if (!filter.contains(ModuleDecl::ImportFilterKind::PackageOnly))
511+
if (!filter.contains(ModuleDecl::ImportFilterKind::PackageOnly) ||
512+
!dep.isLoaded())
513513
continue;
514514

515515
} else {

test/Serialization/access-level-import-dependencies.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ import PrivateDep
123123
// RUN: -enable-library-evolution -enable-testing \
124124
// RUN: -enable-experimental-feature AccessLevelOnImport
125125
// RUN: %target-swift-frontend -typecheck %t/ExporterClient.swift -I %t \
126+
// RUN: -index-system-modules -index-ignore-stdlib -index-store-path %t/idx \
126127
// RUN: -Rmodule-loading 2>&1 | %FileCheck -check-prefixes=CHECK-EXPORTER,HIDDEN-DEP %s
127128
// CHECK-EXPORTER: 'InternalDep' has an ignored transitive dependency on 'HiddenDep'
128129

0 commit comments

Comments
 (0)