@@ -1254,18 +1254,20 @@ module TopModulesExtraction =
12541254 synAccessOption,
12551255 range,
12561256 synModuleOrNamespaceTrivia) ->
1257- if mightHaveAutoOpen synAttributeLists then
1258- // Contents of a module that's potentially AutoOpen are available from its parent without a prefix.
1259- // Stay safe and as soon as the parent module is reachable, consider this module reachable as well
1260- [| LongIdent.Empty |]
1261- else
1262- // 'module A.B' is equivalent to 'namespace A; module B', meaning that 'A' is opened implicitly
12631257 if
1264- synModuleOrNamespaceKind.IsModule && longId.Length > 1
1258+ mightHaveAutoOpen synAttributeLists && synModuleOrNamespaceKind.IsModule
12651259 then
1260+ // Contents of a module that's potentially AutoOpen are available from its parent without a prefix.
1261+ // Stay safe and as soon as the parent module is reachable, consider this module reachable as well
12661262 [| longId.GetSlice( None, Some <| longId.Length - 2 ); longId |]
12671263 else
1268- [| longId |]
1264+ // 'module A.B' is equivalent to 'namespace A; module B', meaning that 'A' is opened implicitly
1265+ if
1266+ synModuleOrNamespaceKind.IsModule && longId.Length > 1
1267+ then
1268+ [| longId.GetSlice( None, Some <| longId.Length - 2 ); longId |]
1269+ else
1270+ [| longId |]
12691271 // TODO Temporarily disabled digging into the file's structure to avoid edge cases where another file depends on this file's namespace existing (but nothing else)
12701272 // synModuleDecls
12711273 // |> moduleDecls
@@ -1307,6 +1309,7 @@ module TopModulesExtraction =
13071309 synAccessOption,
13081310 range) ->
13091311 let idents =
1312+ // TODO Fix this by making it similar to what happens in other places where we detect AutoOpen modules
13101313 if mightHaveAutoOpen synAttributeLists then
13111314 // Contents of a module that's potentially AutoOpen are available everywhere, so treat it as if it had no name ('root' module).
13121315 [| LongIdent.Empty |]
@@ -1326,18 +1329,20 @@ module TopModulesExtraction =
13261329 synAccessOption,
13271330 range,
13281331 synModuleOrNamespaceTrivia) ->
1329- if mightHaveAutoOpen synAttributeLists then
1330- // Contents of a module that's potentially AutoOpen are available from its parent without a prefix.
1331- // Stay safe and as soon as the parent module is reachable, consider this module reachable as well
1332- [| LongIdent.Empty |]
1333- else
1334- // 'module A.B' is equivalent to 'namespace A; module B', meaning that 'A' is opened implicitly
13351332 if
1336- synModuleOrNamespaceKind.IsModule && longId.Length > 1
1333+ mightHaveAutoOpen synAttributeLists && synModuleOrNamespaceKind.IsModule
13371334 then
1335+ // Contents of a module that's potentially AutoOpen are available from its parent without a prefix.
1336+ // Stay safe and as soon as the parent module is reachable, consider this module reachable as well
13381337 [| longId.GetSlice( None, Some <| longId.Length - 2 ); longId |]
13391338 else
1340- [| longId |]
1339+ // 'module A.B' is equivalent to 'namespace A; module B', meaning that 'A' is opened implicitly
1340+ if
1341+ synModuleOrNamespaceKind.IsModule && longId.Length > 1
1342+ then
1343+ [| longId.GetSlice( None, Some <| longId.Length - 2 ); longId |]
1344+ else
1345+ [| longId |]
13411346
13421347 and moduleSigDecls ( x : SynModuleSigDecl list ) : Eit =
13431348 let emptyState = Eit.Nested [||]
0 commit comments