Skip to content

Commit 785e6a7

Browse files
authored
Merge pull request #31 from nojaf/improve-auto-open
2 parents 89d072d + 5ff2fc3 commit 785e6a7

10 files changed

Lines changed: 539 additions & 274 deletions

tests/ParallelTypeCheckingTests/Code/AlwaysLinkDetection.fs

Lines changed: 0 additions & 47 deletions
This file was deleted.

tests/ParallelTypeCheckingTests/Code/DependencyResolution.fs

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
module ParallelTypeCheckingTests.DependencyResolution
22

3-
open System.Linq
43
open FSharp.Compiler.Syntax
54
open ParallelTypeCheckingTests
65

@@ -194,7 +193,6 @@ let mkGraph (files: FileWithAST array) : Graph<int> =
194193
|> Map.ofArray
195194

196195
// Implementation files backed by signatures should be excluded to construct the trie.
197-
// Signature files should link to the implementation index instead.
198196
let trieInput =
199197
Array.choose
200198
(fun f ->
@@ -208,34 +206,19 @@ let mkGraph (files: FileWithAST array) : Graph<int> =
208206

209207
let fileContents = Array.Parallel.map FileContentMapping.mkFileContent files
210208

211-
let filesWithAutoOpen =
212-
Array.choose
213-
(fun f ->
214-
if AlwaysLinkDetection.doesFileHasAutoOpenBehavior f.AST then
215-
Some f.Idx
216-
else
217-
None)
218-
trieInput
219-
220209
let findDependencies (file: FileWithAST) : int * int array =
221210
let fileContent = fileContents.[file.Idx]
222211
let knownFiles = getFileNameBefore files file.Idx
212+
let filesFromRoot = trie.Files |> Set.filter (fun rootIdx -> rootIdx < file.Idx)
223213

224214
// Process all entries of a file and query the trie when required to find the dependent files.
225215
let result =
226216
// Seq is faster than List in this case.
227-
Seq.fold (processStateEntry queryTrie) (FileContentQueryState.Create file.Idx knownFiles) fileContent
217+
Seq.fold (processStateEntry queryTrie) (FileContentQueryState.Create file.Idx knownFiles filesFromRoot) fileContent
228218

229219
// after processing the file we should verify if any of the open statements are found in the trie but do not yield any file link.
230220
let ghostDependencies = collectGhostDependencies file.Idx trie queryTrie result
231221

232-
// Automatically add all files that came before the current file that use the [<AutoOpen>] attribute.
233-
let topLevelAutoOpenFiles =
234-
if Array.isEmpty filesWithAutoOpen then
235-
Array.empty
236-
else
237-
[| 0 .. (file.Idx - 1) |].Intersect(filesWithAutoOpen).ToArray()
238-
239222
// Automatically add a link from an implementation to its signature file (if present)
240223
let signatureDependency =
241224
match Map.tryFind file.Idx implToSig with
@@ -246,7 +229,6 @@ let mkGraph (files: FileWithAST array) : Graph<int> =
246229
[|
247230
yield! result.FoundDependencies
248231
yield! ghostDependencies
249-
yield! topLevelAutoOpenFiles
250232
yield! signatureDependency
251233
|]
252234
|> Array.distinct

0 commit comments

Comments
 (0)