Skip to content

Commit

Permalink
Keep inline keyword in signature type member. Fixes #1399. (#1410)
Browse files Browse the repository at this point in the history
  • Loading branch information
nojaf committed Jan 29, 2021
1 parent cf452cb commit 7eede44
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
46 changes: 46 additions & 0 deletions src/Fantomas.Tests/SignatureTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1105,3 +1105,49 @@ module Teq =
val domainOf<'domain1, 'domain2, 'range1, 'range2> :
Teq<'domain1 -> 'range1, 'domain2 -> 'range2> -> Teq<'domain1, 'domain2>
"""

[<Test>]
let ``inline type definition member, 1399`` () =
formatSourceString
true
"""
namespace Baz
[<Sealed>]
type Foo =
member inline Return : 'a -> Baz<'a>
"""
config
|> prepend newline
|> should
equal
"""
namespace Baz
[<Sealed>]
type Foo =
member inline Return: 'a -> Baz<'a>
"""

[<Test>]
let ``inline private type definition member`` () =
formatSourceString
true
"""
namespace Baz
[<Sealed>]
type Foo =
member inline private Return : 'a -> Baz<'a>
"""
config
|> prepend newline
|> should
equal
"""
namespace Baz
[<Sealed>]
type Foo =
member inline private Return: 'a -> Baz<'a>
"""
3 changes: 2 additions & 1 deletion src/Fantomas/CodePrinter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3714,7 +3714,7 @@ and genMemberSig astContext node =
| SynMemberSig.NestedType (_, r) -> r, SynMemberSig_NestedType

match node with
| MSMember (Val (ats, px, ao, s, t, vi, _, ValTyparDecls (tds, _, tcs)), mf) ->
| MSMember (Val (ats, px, ao, s, t, vi, isInline, ValTyparDecls (tds, _, tcs)), mf) ->
let (FunType namedArgs) = (t, vi)

let isFunctionProperty =
Expand All @@ -3735,6 +3735,7 @@ and genMemberSig astContext node =
InterfaceRange = None }
mf
range
+> ifElse isInline (!- "inline ") sepNone
+> opt sepSpace ao genAccess
+> ifElse (s = "``new``") (!- "new") (!-s)
+> genTypeParamPostfix astContext tds tcs
Expand Down

0 comments on commit 7eede44

Please sign in to comment.