Skip to content

Commit

Permalink
Don't append Module for types with arguments. (#1772)
Browse files Browse the repository at this point in the history
Don't implicitly append 'Module' to module names if the type with the
same name as the module has a type argument. In that case the name is
not ambiguous.
In addition, the current situation breaks these fairly common use cases
for libraries that need to interoperate with other .NET languages, as
with the new compiler some modules will suddenly gain a Module suffix.
There is no way to turn this off, short of making the module into a
static class, which is silly.
  • Loading branch information
kurtschelfthout authored and KevinRansom committed Nov 21, 2016
1 parent c1ea283 commit 9367586
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
18 changes: 10 additions & 8 deletions src/fsharp/TypeChecker.fs
Original file line number Diff line number Diff line change
Expand Up @@ -16059,10 +16059,11 @@ and TcSignatureElementsNonMutRec cenv parent endm env defs =
[ for def in defs do
match def with
| SynModuleSigDecl.Types (typeSpecs,_) ->
for (TypeDefnSig(ComponentInfo(_,_,_,ids,_,_,_,_),trepr,extraMembers,_)) in typeSpecs do
match trepr with
| SynTypeDefnSigRepr.Simple((SynTypeDefnSimpleRepr.None _),_) when not (isNil extraMembers) -> ()
| _ -> yield (List.last ids).idText
for (TypeDefnSig(ComponentInfo(_,typars,_,ids,_,_,_,_),trepr,extraMembers,_)) in typeSpecs do
if isNil typars then
match trepr with
| SynTypeDefnSigRepr.Simple((SynTypeDefnSimpleRepr.None _),_) when not (isNil extraMembers) -> ()
| _ -> yield (List.last ids).idText
| _ -> () ]
|> set

Expand Down Expand Up @@ -16487,10 +16488,11 @@ and TcModuleOrNamespaceElements cenv parent endm env xml mutRecNSInfo defs =
[ for def in defs do
match def with
| SynModuleDecl.Types (typeSpecs,_) ->
for (TypeDefn(ComponentInfo(_,_,_,ids,_,_,_,_),trepr,_,_)) in typeSpecs do
match trepr with
| SynTypeDefnRepr.ObjectModel(TyconAugmentation,_,_) -> ()
| _ -> yield (List.last ids).idText
for (TypeDefn(ComponentInfo(_,typars,_,ids,_,_,_,_),trepr,_,_)) in typeSpecs do
if isNil typars then
match trepr with
| SynTypeDefnRepr.ObjectModel(TyconAugmentation,_,_) -> ()
| _ -> yield (List.last ids).idText
| _ -> () ]
|> set

Expand Down
4 changes: 2 additions & 2 deletions tests/fsharp/core/longnames/test.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -528,8 +528,8 @@ module Ok9b =
let create() = 1
type Dummy = A | B


test "lkneecec09iew9" (typeof<A.Dummy>.FullName.Contains("AModule") )
//A<'T> has a type parameter, so appending Module is not necessary.
test "lkneecec09iew9" (not (typeof<A.Dummy>.FullName.Contains("AModule") ) )

module rec Ok10 =

Expand Down

0 comments on commit 9367586

Please sign in to comment.