@@ -432,24 +432,35 @@ type InteractiveChecker internal (compilerStateCache) =
432
432
433
433
let filePairs = FilePairMap( sourceFiles)
434
434
let graph , _trie = DependencyResolution.mkGraph filePairs sourceFiles
435
- let findTransitiveDependencies ( startNode : FileIndex ) : FileIndex array =
435
+ let findTransitiveDependentFiles ( startNode : FileIndex ) : FileIndex array =
436
436
let rec dfs ( node : FileIndex ) ( visited : Set < FileIndex >) ( acc : FileIndex array ) : FileIndex array =
437
437
if ( Set.contains node visited) then
438
438
acc
439
439
else
440
- let neighbors = graph.[ node]
441
- let visited ' = Set.add node visited
442
-
443
- let acc ' =
444
- Array.fold ( fun innerAcc neighbor -> dfs neighbor visited' innerAcc) acc neighbors
445
-
446
- [| yield ! acc' ; yield node |]
440
+ let newVisited = Set.add node visited
441
+
442
+ let consumers =
443
+ // Last node in the project cannot have
444
+ if node = graph.Count - 1 then
445
+ acc
446
+ else
447
+ // Look if the next nodes depend on the current node
448
+ [| ( node + 1 ) .. ( graph.Count - 1 ) |]
449
+ |> Array.fold
450
+ ( fun innerAcc nextIdx ->
451
+ if not ( Array.contains node graph.[ nextIdx]) then
452
+ innerAcc
453
+ else
454
+ dfs nextIdx newVisited innerAcc)
455
+ acc
456
+
457
+ [| yield node; yield ! consumers |]
447
458
448
459
dfs startNode Set.empty Array.empty
449
460
|> Array.sort
450
461
451
462
let dependentFiles =
452
- findTransitiveDependencies currentFileIdx
463
+ findTransitiveDependentFiles currentFileIdx
453
464
|> Array.sort
454
465
|> Array.map ( fun idx -> Array.item idx fileNames)
455
466
0 commit comments