@@ -106,10 +106,11 @@ extension ModuleDependencyGraph {
106106
107107// MARK: - Getting a graph read from priors ready to use
108108extension ModuleDependencyGraph {
109- func collectNodesDirectlyInvalidatedByChangedOrAddedExternals( ) -> Set < Node > {
110- fingerprintedExternalDependencies. reduce ( into: Set ( ) ) { invalidatedNodes, fed in
109+ func collectNodesInvalidatedByChangedOrAddedExternals( ) -> DirectlyInvalidatedNodes {
110+ fingerprintedExternalDependencies. reduce ( into: DirectlyInvalidatedNodes ( ) ) {
111+ invalidatedNodes, fed in
111112 invalidatedNodes. formUnion (
112- self . collectNodesDirectlyInvalidatedByProcessing ( fingerprintedExternalDependency: fed) )
113+ self . collectNodesInvalidatedByProcessing ( fingerprintedExternalDependency: fed) )
113114 }
114115 }
115116}
@@ -140,7 +141,7 @@ extension ModuleDependencyGraph {
140141 ) -> Set < DependencySource > {
141142 let nodes = nodeFinder. findNodes ( for: dependencySource) ?? [ : ]
142143 /// Tests expect this to be reflexive
143- return collectSwiftDepsUsingTransitivelyInvalidated ( nodes: nodes. values)
144+ return collectSwiftDepsUsingTransitivelyInvalidated ( nodes: DirectlyInvalidatedNodes ( nodes. values) )
144145 }
145146
146147 /// Does the graph contain any dependency nodes for a given source-code file?
@@ -188,10 +189,9 @@ extension ModuleDependencyGraph {
188189 /// Given a set of invalidated nodes, find all swiftDeps dependency sources containing defs that transitively use
189190 /// any of the invalidated nodes.
190191 /*@_spi(Testing)*/
191- public func collectSwiftDepsUsingTransitivelyInvalidated< Nodes : Sequence > (
192- nodes: Nodes
192+ public func collectSwiftDepsUsingTransitivelyInvalidated(
193+ nodes: DirectlyInvalidatedNodes
193194 ) -> Set < DependencySource >
194- where Nodes. Element == Node
195195 {
196196 // Is this correct for the 1st wave after having read a prior?
197197 // Yes, because
@@ -214,9 +214,9 @@ extension ModuleDependencyGraph {
214214 /// Given an external dependency & its fingerprint, find any nodes directly using that dependency.
215215 /// As an optimization, only return the nodes that have not been already traced, because the traced nodes
216216 /// will have already been used to schedule jobs to run.
217- /*@_spi(Testing)*/ public func collectUntracedNodesDirectlyUsing (
217+ /*@_spi(Testing)*/ public func collectUntracedNodesUsing (
218218 _ fingerprintedExternalDependency: FingerprintedExternalDependency
219- ) -> Set < Node > {
219+ ) -> DirectlyInvalidatedNodes {
220220 // These nodes will depend on the *interface* of the external Decl.
221221 let key = DependencyKey (
222222 aspect: . interface,
@@ -227,9 +227,10 @@ extension ModuleDependencyGraph {
227227 let node = Node ( key: key,
228228 fingerprint: fingerprintedExternalDependency. fingerprint,
229229 dependencySource: nil )
230- return nodeFinder
231- . uses ( of: node)
232- . filter ( { use in use. isUntraced } )
230+ return DirectlyInvalidatedNodes (
231+ nodeFinder
232+ . uses ( of: node)
233+ . filter ( { use in use. isUntraced } ) )
233234 }
234235
235236 /// Find all the inputs known to need recompilation as a consequence of reading a swiftdeps or swiftmodule
@@ -252,16 +253,16 @@ extension ModuleDependencyGraph {
252253 /// If reading for the first time, the driver is compiling all outdated source files anyway, so only
253254 /// nodes invalidated by external dependencies matter.
254255 /// But when updating, all invalidations matter.
255- let directlyInvalidatedNodes = phase. isUpdating
256- ? results. allDirectlyInvalidatedNodes
257- : results. nodesDirectlyInvalidatedByUsingSomeExternal
256+ let invalidatedNodes = phase. isUpdating
257+ ? results. all
258+ : results. usesOfSomeExternal
258259
259- return collectInputsUsingTransitivelyInvalidated ( nodes: directlyInvalidatedNodes )
260+ return collectInputsUsingTransitivelyInvalidated ( nodes: invalidatedNodes )
260261 }
261262
262263 /// Given nodes that are invalidated, find all the affected inputs that must be recompiled.
263264 func collectInputsUsingTransitivelyInvalidated(
264- nodes directlyInvalidatedNodes: Set < Node >
265+ nodes directlyInvalidatedNodes: DirectlyInvalidatedNodes
265266 ) -> Set < TypedVirtualPath > {
266267 collectSwiftDepsUsingTransitivelyInvalidated ( nodes: directlyInvalidatedNodes)
267268 . reduce ( into: Set ( ) ) { invalidatedInputs, invalidatedSwiftDeps in
@@ -277,9 +278,9 @@ extension ModuleDependencyGraph {
277278 /// Return the nodes thus invalidated.
278279 /// But always integrate, in order to detect future changes.
279280 /// This function does not to the transitive closure; that is left to the callers
280- func collectNodesDirectlyInvalidatedByProcessing (
281+ func collectNodesInvalidatedByProcessing (
281282 fingerprintedExternalDependency fed: FingerprintedExternalDependency )
282- -> Set < Node > {
283+ -> DirectlyInvalidatedNodes {
283284
284285 let isNewToTheGraph = fingerprintedExternalDependencies. insert ( fed) . inserted
285286
@@ -293,13 +294,13 @@ extension ModuleDependencyGraph {
293294 ( isNewToTheGraph || lazyModTimer. hasExternalFileChanged)
294295
295296 // Do this no matter what in order to integrate any incremental external dependencies.
296- let directlyInvalidatedNodesFromIncrementalExternal = shouldTryToProcess
297- ? collectNodesDirectlyInvalidatedByAttemptingToProcess ( fed, info)
297+ let invalidatedNodesFromIncrementalExternal = shouldTryToProcess
298+ ? collectNodesInvalidatedByAttemptingToProcess ( fed, info)
298299 : nil
299300
300301 if phase == . buildingAfterEachCompilation {
301302 // going to compile every input anyway, less work for callers
302- return Set ( )
303+ return DirectlyInvalidatedNodes ( )
303304 }
304305
305306 /// When building a graph from scratch, an unchanged but new-to-the-graph external dependendcy should be ignored.
@@ -308,12 +309,12 @@ extension ModuleDependencyGraph {
308309 lazyModTimer. hasExternalFileChanged
309310
310311 guard callerWantsTheseChanges else {
311- return Set ( )
312+ return DirectlyInvalidatedNodes ( )
312313 }
313314
314315 // If there was an error integrating the external dependency, or if it was not an incremental one,
315316 // return anything that uses that dependency.
316- return directlyInvalidatedNodesFromIncrementalExternal ?? collectUntracedNodesDirectlyUsing ( fed)
317+ return invalidatedNodesFromIncrementalExternal ?? collectUntracedNodesUsing ( fed)
317318 }
318319
319320 private struct LazyModTimer {
@@ -326,15 +327,15 @@ extension ModuleDependencyGraph {
326327
327328 /// Try to read and integrate an external dependency.
328329 /// Return nil if it's not incremental, or if an error occurs.
329- private func collectNodesDirectlyInvalidatedByAttemptingToProcess (
330+ private func collectNodesInvalidatedByAttemptingToProcess (
330331 _ fed: FingerprintedExternalDependency ,
331- _ info: IncrementalCompilationState . InitialStateComputer ) -> Set < Node > ? {
332+ _ info: IncrementalCompilationState . InitialStateComputer ) -> DirectlyInvalidatedNodes ? {
332333 fed. incrementalDependencySource?
333334 . read ( in: info. fileSystem, reporter: info. reporter)
334335 . map { unserializedDepGraph in
335336 info. reporter? . report ( " Integrating changes from: \( fed. externalDependency) " )
336337 return Integrator . integrate ( from: unserializedDepGraph, into: self )
337- . allDirectlyInvalidatedNodes
338+ . all
338339 }
339340 }
340341
@@ -364,10 +365,8 @@ extension OutputFileMap {
364365// MARK: - tracking traced nodes
365366extension ModuleDependencyGraph {
366367
367- func ensureGraphWillRetrace< Nodes: Sequence > ( _ nodes: Nodes )
368- where Nodes. Element == Node
369- {
370- for node in nodes {
368+ func ensureGraphWillRetrace( _ nodes: DirectlyInvalidatedNodes ) {
369+ for node in nodes. contents {
371370 node. setUntraced ( )
372371 }
373372 }
0 commit comments