Skip to content

Commit

Permalink
Merge pull request #14 from safesparrow/tcSigEnv-merging-updated
Browse files Browse the repository at this point in the history
  • Loading branch information
safesparrow committed Nov 10, 2022
2 parents e550115 + 9fa6952 commit 9857439
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 15 deletions.
6 changes: 4 additions & 2 deletions src/Compiler/Driver/ParseAndCheckInputs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1470,15 +1470,17 @@ let CheckOneInputAux'
let fsiPartialResult, tcState =
let rootSigs = Zmap.add qualNameOfFile sigFileType tcState.tcsRootSigs

let tcSigEnv =
AddLocalRootModuleOrNamespace TcResultsSink.NoSink tcGlobals amap m tcState.tcsTcSigEnv sigFileType

// Add the signature to the signature env (unless it had an explicit signature)
let ccuSigForFile = CombineCcuContentFragments [ sigFileType; tcState.tcsCcuSig ]

let partialResult = tcEnv, EmptyTopAttrs, None, ccuSigForFile

let tcState =
{ tcState with
tcsTcSigEnv = tcEnv
tcsTcImplEnv = tcState.tcsTcImplEnv
tcsTcSigEnv = tcSigEnv
tcsRootSigs = rootSigs
tcsCreatesGeneratedProvidedTypes =
tcState.tcsCreatesGeneratedProvidedTypes || createsGeneratedProvidedTypes
Expand Down
11 changes: 0 additions & 11 deletions tests/ParallelTypeCheckingTests/Code/DependencyResolution.fs
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,6 @@ module internal DependencyResolution =

let trie = buildTrie nodes

let fsiFiles =
nodes
|> Array.filter (fun f ->
match f.File.AST with
| ASTOrFsix.AST (ParsedInput.SigFile _) -> true
| _ -> false)

let processFile (node: FileData) =
let deps =
let fsiDep =
Expand Down Expand Up @@ -231,17 +224,13 @@ module internal DependencyResolution =
// Process module refs in order, marking more and more TrieNodes as reachable and potential prefixes
moduleRefs |> Array.iter processRef

// Force .fsi files to depend on all other (previous) .fsi files - avoids the issue of TcEnv being overriden
let additionalFsiDeps = if node.File.Name.EndsWith ".fsi" then nodes else [||]

// Collect files from all reachable TrieNodes
let deps =
reachable
|> Seq.collect (fun node -> node.Files)
// Assume that this file depends on all files that have any module abbreviations - this is probably unnecessary.
// TODO Handle module abbreviations in a better way
|> Seq.append filesWithModuleAbbreviations
|> Seq.append additionalFsiDeps
|> Seq.append fsiDep
|> Seq.map (fun f -> f.File)
|> Seq.toArray
Expand Down
75 changes: 74 additions & 1 deletion tests/ParallelTypeCheckingTests/Tests/TestCompilation.fs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,80 @@ open A
]
|> FProject.Make CompileOutput.Library

let all = [ encodeDecodeSimple; diamondBroken1; fsFsi; emptyNamespace ]
let dependentSignatures =
[
"A.fsi",
"""
module A
type AType = class end
"""
"A.fs",
"""
module A
type AType = class end
"""
"B.fsi",
"""
module B
open A
val b: AType -> unit
"""
"B.fs",
"""
module B
open A
let b (a:AType) = ()
"""
"C.fsi",
"""
module C
type CType = class end
"""
"C.fs",
"""
module C
type CType = class end
"""
"D.fsi",
"""
module D
open A
open C
val d: CType -> unit
"""
"D.fs",
"""
module D
open A
open B
open C
let d (c: CType) =
let a : AType = failwith "todo"
b a
"""
]
|> FProject.Make CompileOutput.Library

let all =
[
encodeDecodeSimple
diamondBroken1
fsFsi
emptyNamespace
dependentSignatures
]

type Case =
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ let ``Analyse whole projects and print statistics`` (projectFile: string) =
files
|> Array.Parallel.mapi (fun i f ->
let code = System.IO.File.ReadAllText(f)
let ast = getParseResults code
let ast = parseSourceCode (f, code)

{
Idx = FileIdx.make i
Expand Down

0 comments on commit 9857439

Please sign in to comment.