@@ -59,16 +59,7 @@ import protocol TSCBasic.FileSystem
5959extension InterModuleDependencyGraph {
6060 var topologicalSorting : [ ModuleDependencyId ] {
6161 get throws {
62- try topologicalSort ( Array ( modules. keys) ,
63- successors: {
64- var dependencies : [ ModuleDependencyId ] = [ ]
65- let moduleInfo = try moduleInfo ( of: $0)
66- dependencies. append ( contentsOf: moduleInfo. directDependencies ?? [ ] )
67- if case . swift( let swiftModuleDetails) = moduleInfo. details {
68- dependencies. append ( contentsOf: swiftModuleDetails. swiftOverlayDependencies ?? [ ] )
69- }
70- return dependencies
71- } )
62+ try topologicalSort ( Array ( modules. keys) , successors: { try Array ( moduleInfo ( of: $0) . allDependencies) } )
7263 }
7364 }
7465
@@ -91,22 +82,9 @@ extension InterModuleDependencyGraph {
9182 }
9283 // Traverse the set of modules in reverse topological order, assimilating transitive closures
9384 for moduleId in topologicalIdList. reversed ( ) {
94- let moduleInfo = try moduleInfo ( of: moduleId)
95- for dependencyId in moduleInfo. directDependencies! {
85+ for dependencyId in try moduleInfo ( of: moduleId) . allDependencies {
9686 transitiveClosureMap [ moduleId] !. formUnion ( transitiveClosureMap [ dependencyId] !)
9787 }
98- // For Swift dependencies, their corresponding Swift Overlay dependencies
99- // and bridging header dependencies are equivalent to direct dependencies.
100- if case . swift( let swiftModuleDetails) = moduleInfo. details {
101- let swiftOverlayDependencies = swiftModuleDetails. swiftOverlayDependencies ?? [ ]
102- for dependencyId in swiftOverlayDependencies {
103- transitiveClosureMap [ moduleId] !. formUnion ( transitiveClosureMap [ dependencyId] !)
104- }
105- let bridgingHeaderDependencies = swiftModuleDetails. bridgingHeaderDependencies ?? [ ]
106- for dependencyId in bridgingHeaderDependencies {
107- transitiveClosureMap [ moduleId] !. formUnion ( transitiveClosureMap [ dependencyId] !)
108- }
109- }
11088 }
11189 // For ease of use down-the-line, remove the node's self from its set of reachable nodes
11290 for (key, _) in transitiveClosureMap {
@@ -167,7 +145,7 @@ internal extension InterModuleDependencyGraph {
167145 var visited : Set < ModuleDependencyId > = [ ]
168146 // Scan from the main module's dependencies to avoid reporting
169147 // the main module itself in the results.
170- for dependencyId in mainModuleInfo. directDependencies ?? [ ] {
148+ for dependencyId in mainModuleInfo. allDependencies {
171149 try outOfDateModuleScan ( from: dependencyId, visited: & visited,
172150 modulesRequiringRebuild: & modulesRequiringRebuild,
173151 fileSystem: fileSystem, cas: cas, forRebuild: forRebuild,
@@ -225,7 +203,7 @@ internal extension InterModuleDependencyGraph {
225203 let sourceModuleInfo = try moduleInfo ( of: sourceModuleId)
226204 // Visit the module's dependencies
227205 var hasOutOfDateModuleDependency = false
228- for dependencyId in sourceModuleInfo. directDependencies ?? [ ] {
206+ for dependencyId in sourceModuleInfo. allDependencies {
229207 // If we have not already visited this module, recurse.
230208 if !visited. contains ( dependencyId) {
231209 try outOfDateModuleScan ( from: dependencyId, visited: & visited,
@@ -319,7 +297,7 @@ internal extension InterModuleDependencyGraph {
319297 }
320298
321299 // Check if a dependency of this module has a newer output than this module
322- for dependencyId in checkedModuleInfo. directDependencies ?? [ ] {
300+ for dependencyId in checkedModuleInfo. allDependencies {
323301 let dependencyInfo = try moduleInfo ( of: dependencyId)
324302 if !verifyInputOlderThanOutputModTime( moduleID. moduleName,
325303 VirtualPath . lookup ( dependencyInfo. modulePath. path) ,
@@ -409,21 +387,14 @@ internal extension InterModuleDependencyGraph {
409387 // depends on a corresponding Clang module with the same name.
410388 // If it does, add it to the path as well.
411389 var completePath = pathSoFar
412- if let dependencies = sourceInfo. directDependencies,
413- dependencies. contains ( . clang( source. moduleName) ) {
390+ if sourceInfo. allDependencies. contains ( . clang( source. moduleName) ) {
414391 completePath. append ( . clang( source. moduleName) )
415392 }
416393 result = completePath
417394 return true
418395 }
419396
420- var allDependencies = sourceInfo. directDependencies ?? [ ]
421- if case . swift( let swiftModuleDetails) = sourceInfo. details,
422- let overlayDependencies = swiftModuleDetails. swiftOverlayDependencies {
423- allDependencies. append ( contentsOf: overlayDependencies)
424- }
425-
426- for dependency in allDependencies {
397+ for dependency in sourceInfo. allDependencies {
427398 if !visited. contains ( dependency) ,
428399 try findAPath ( source: dependency,
429400 pathSoFar: pathSoFar + [ dependency] ,
@@ -446,20 +417,14 @@ internal extension InterModuleDependencyGraph {
446417 // depends on a corresponding Clang module with the same name.
447418 // If it does, add it to the path as well.
448419 var completePath = pathSoFar
449- if let dependencies = sourceInfo. directDependencies,
450- dependencies. contains ( . clang( source. moduleName) ) {
420+ if sourceInfo. allDependencies. contains ( . clang( source. moduleName) ) {
451421 completePath. append ( . clang( source. moduleName) )
452422 }
453423 results. insert ( completePath)
454424 return
455425 }
456426
457- var allDependencies = sourceInfo. directDependencies ?? [ ]
458- if case . swift( let swiftModuleDetails) = sourceInfo. details,
459- let overlayDependencies = swiftModuleDetails. swiftOverlayDependencies {
460- allDependencies. append ( contentsOf: overlayDependencies)
461- }
462- for dependency in allDependencies {
427+ for dependency in sourceInfo. allDependencies {
463428 try findAllPaths ( source: dependency,
464429 pathSoFar: pathSoFar + [ dependency] ,
465430 results: & results,
0 commit comments