Skip to content

Commit e50568c

Browse files
committed
[DependencyScanning] Make 'ModuleInfo.ImportInfos' 'nil' when using a toolchain which does not support querying them.
1 parent 367f7aa commit e50568c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Sources/SwiftDriver/SwiftScan/DependencyGraphBuilder.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,19 +104,19 @@ private extension SwiftScan {
104104
}
105105
}
106106

107-
var importInfos: [ImportInfo] = []
107+
var importInfos: [ImportInfo]? = nil
108108
if supportsImportInfos {
109109
let importInfoSetRefOrNull = api.swiftscan_module_info_get_imports(moduleInfoRef)
110110
guard let importInfoSetRef = importInfoSetRefOrNull else {
111111
throw DependencyScanningError.missingField("dependency_graph.imports")
112112
}
113113
let importInfoRefArray = Array(UnsafeBufferPointer(start: importInfoSetRef.pointee.imports,
114114
count: Int(importInfoSetRef.pointee.count)))
115-
for importInfoRefOrNull in importInfoRefArray {
115+
importInfos = try importInfoRefArray.map { importInfoRefOrNull in
116116
guard let importInfoRef = importInfoRefOrNull else {
117117
throw DependencyScanningError.missingField("dependency_set_t.imports[_]")
118118
}
119-
importInfos.append(try constructImportInfo(from: importInfoRef))
119+
return try constructImportInfo(from: importInfoRef)
120120
}
121121
}
122122

0 commit comments

Comments
 (0)