Skip to content

Commit 48e4194

Browse files
committed
Add support for single identifier module abbreviations.
1 parent 789174c commit 48e4194

3 files changed

Lines changed: 24 additions & 2 deletions

File tree

tests/ParallelTypeCheckingTests/Code/FileContentMapping.fs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ let visitLongIdent (lid: LongIdent) =
2828
| [ _ ] -> []
2929
| lid -> [ FileContentEntry.PrefixedIdentifier(longIdentToPath true lid) ]
3030

31+
let visitLongIdentForModuleAbbrev (lid: LongIdent) =
32+
match lid with
33+
| [] -> []
34+
| lid -> [ FileContentEntry.PrefixedIdentifier(longIdentToPath false lid) ]
35+
3136
let visitSynAttribute (a: SynAttribute) : FileContentEntry list =
3237
[ yield! visitSynLongIdent a.TypeName; yield! visitSynExpr a.ArgExpr ]
3338

@@ -55,7 +60,7 @@ let visitSynModuleDecl (decl: SynModuleDecl) : FileContentEntry list =
5560
| SynModuleDecl.ModuleAbbrev (longId = longId) ->
5661
// I believe this is enough
5762
// A module abbreviation doesn't appear to be exposed as part of the current module/namespace
58-
visitLongIdent longId
63+
visitLongIdentForModuleAbbrev longId
5964
| SynModuleDecl.NamespaceFragment _ -> []
6065
| SynModuleDecl.Exception(exnDefn = SynExceptionDefn (exnRepr = SynExceptionDefnRepr (attributes = attributes
6166
caseName = caseName
@@ -79,7 +84,7 @@ let visitSynModuleSigDecl (md: SynModuleSigDecl) =
7984
yield FileContentEntry.NestedModule(ident.idText, lc visitSynModuleSigDecl decls)
8085
]
8186
| SynModuleSigDecl.NestedModule _ -> failwith "A nested module cannot have multiple identifiers"
82-
| SynModuleSigDecl.ModuleAbbrev _ -> failwith "no support for module abbreviations"
87+
| SynModuleSigDecl.ModuleAbbrev (longId = longId) -> visitLongIdentForModuleAbbrev longId
8388
| SynModuleSigDecl.Val (valSig, _) -> visitSynValSig valSig
8489
| SynModuleSigDecl.Types (types = types) -> lc visitSynTypeDefnSig types
8590
| SynModuleSigDecl.Exception(exnSig = SynExceptionSig (exnRepr = SynExceptionDefnRepr (attributes = attributes

tests/ParallelTypeCheckingTests/Tests/FileContentMappingTests.fs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,18 @@ module Z =
106106
match content with
107107
| [ TopLevelNamespace "X" [ NestedModule "Z" [] ] ] -> Assert.Pass()
108108
| content -> Assert.Fail($"Unexpected content: {content}")
109+
110+
[<Test>]
111+
let ``Single ident module abbreviation`` () =
112+
let content =
113+
getContent
114+
true
115+
"""
116+
module A
117+
118+
module B = C
119+
"""
120+
121+
match content with
122+
| [ TopLevelNamespace "" [ PrefixedIdentifier "C" ] ] -> Assert.Pass()
123+
| content -> Assert.Fail($"Unexpected content: {content}")

tests/ParallelTypeCheckingTests/Tests/Scenarios.fs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,8 @@ exception BakedInMemberConstraintName of string
465465
"""
466466
namespace FSharp.Compiler.CodeAnalysis
467467
468+
open FSharp.Compiler
469+
468470
module Tc = CheckExpressions
469471
"""
470472
(set [| 0 |])

0 commit comments

Comments
 (0)