Skip to content

Commit 7ce5d00

Browse files
committed
WIP
1 parent 03d820a commit 7ce5d00

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

tests/FSharp.Compiler.Service.Tests2/DepResolving.fs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,8 @@ type B = int
309309
let Test () =
310310
log "start"
311311
let m = AnalyzerManager()
312-
let projectFile = @"C:\projekty\fsharp\fsharp_main\src\Compiler\FSharp.Compiler.Service.fsproj"
312+
//let projectFile = @"C:\projekty\fsharp\fsharp_main\src\Compiler\FSharp.Compiler.Service.fsproj"
313+
let projectFile = @"C:\projekty\fsharp\heuristic\tests\FSharp.Compiler.ComponentTests\FSharp.Compiler.ComponentTests.fsproj"
313314
let analyzer = m.GetProject(projectFile)
314315
let results = analyzer.Build()
315316
log "built"

tests/FSharp.Compiler.Service.Tests2/TypeTests.fs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1034,6 +1034,16 @@ and visit (input : ParsedInput) =
10341034
|> Seq.collect visitSynModuleOrNamespace
10351035
|> Seq.toArray
10361036

1037+
let mightHaveAutoOpen (synAttributeLists : SynAttributeList list) : bool =
1038+
let attributes =
1039+
synAttributeLists
1040+
|> List.collect (fun attributes -> attributes.Attributes)
1041+
match attributes with
1042+
// No attributes found - no [<AutoOpen>] possible
1043+
| [] -> false
1044+
// Some attributes found - we can't know for sure if one of them is the AutoOpenAttribute (possibly hidden with a type alias), so we say 'yes'.
1045+
| _ -> true
1046+
10371047
let topModuleOrNamespace (input : ParsedInput) =
10381048
match input with
10391049
| ParsedInput.ImplFile f ->
@@ -1042,7 +1052,12 @@ let topModuleOrNamespace (input : ParsedInput) =
10421052
| first :: rest ->
10431053
match first with
10441054
| SynModuleOrNamespace(longId, isRecursive, synModuleOrNamespaceKind, synModuleDecls, preXmlDoc, synAttributeLists, synAccessOption, range, synModuleOrNamespaceTrivia) ->
1045-
longId
1055+
if mightHaveAutoOpen synAttributeLists then
1056+
// Contents of a module that's potentially AutoOpen are available everywhere, so treat it as if it had no name ('root' module).
1057+
// This makes the dependency tracking algorithm detect it as a dependency for all further files.
1058+
LongIdent.Empty
1059+
else
1060+
longId
10461061
| ParsedInput.SigFile _ ->
10471062
failwith "Sig files not supported atm"
10481063

0 commit comments

Comments
 (0)