Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Put long return types on the next line of SynModuleSigDecl.Val #1184

Merged
merged 1 commit into from
Oct 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 36 additions & 8 deletions src/Fantomas.Tests/SignatureTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -433,20 +433,20 @@ module Teq =
val domain<'domain1, 'domain2, 'range> : Teq<'domain1, 'domain2> -> Teq<'domain1 -> 'range, 'domain2 -> 'range>

/// Given a type equality between two function types, returns the type equality on their corresponding domains.
val domainOf<'domain1, 'domain2, 'range1, 'range2> : Teq<'domain1 -> 'range1, 'domain2 -> 'range2>
-> Teq<'domain1, 'domain2>
val domainOf<'domain1, 'domain2, 'range1, 'range2> :
Teq<'domain1 -> 'range1, 'domain2 -> 'range2> -> Teq<'domain1, 'domain2>

/// Given a type equality between two types 'range1 and 'range2, returns the type equality
/// on the function types ('domain -> 'range1) and ('domain -> 'range2), for any arbitrary 'domain.
val range<'domain, 'range1, 'range2> : Teq<'range1, 'range2> -> Teq<'domain -> 'range1, 'domain -> 'range2>

/// Given a type equality between two function types, returns the type equality on their corresponding ranges.
val rangeOf<'domain1, 'domain2, 'range1, 'range2> : Teq<'domain1 -> 'range1, 'domain2 -> 'range2>
-> Teq<'range1, 'range2>
val rangeOf<'domain1, 'domain2, 'range1, 'range2> :
Teq<'domain1 -> 'range1, 'domain2 -> 'range2> -> Teq<'range1, 'range2>

/// Given a pair of type equalities, one for domains and one for ranges, returns the type equality for the corresponding function types.
val func<'domain1, 'range1, 'domain2, 'range2> : Teq<'domain1, 'domain2>
-> Teq<'range1, 'range2> -> Teq<'domain1 -> 'range1, 'domain2 -> 'range2>
val func<'domain1, 'range1, 'domain2, 'range2> :
Teq<'domain1, 'domain2> -> Teq<'range1, 'range2> -> Teq<'domain1 -> 'range1, 'domain2 -> 'range2>

/// Given a type equality between two types 'fst1 and 'fst2, returns the type equality
/// on the pair types ('fst1 * 'snd) and ('fst2 * 'snd), for any arbitrary 'snd.
Expand All @@ -458,8 +458,8 @@ module Teq =

/// Given a pair of type equalities, one for the first element of a pair and one for the second element of a pair,
/// returns the type equality for the corresponding pair types.
val pair<'fst1, 'snd1, 'fst2, 'snd2> : Teq<'fst1, 'fst2>
-> Teq<'snd1, 'snd2> -> Teq<'fst1 * 'snd1, 'fst2 * 'snd2>
val pair<'fst1, 'snd1, 'fst2, 'snd2> :
Teq<'fst1, 'fst2> -> Teq<'snd1, 'snd2> -> Teq<'fst1 * 'snd1, 'fst2 * 'snd2>
"""

[<Test>]
Expand Down Expand Up @@ -899,3 +899,31 @@ type TestType =
// Some more comments
private { Meh: TimeSpan }
"""

[<Test>]
let ``format long val return type multiline, 1181`` () =
formatSourceString true """
namespace TypeEquality

[<RequireQualifiedAccess>]
module Teq =

[<RequireQualifiedAccess>]
module Cong =

val domainOf<'domain1, 'domain2, 'range1, 'range2> : Teq<'domain1 -> 'range1, 'domain2 -> 'range2>
-> Teq<'domain1, 'domain2>
""" { config with SpaceBeforeColon = true }
|> prepend newline
|> should equal """
namespace TypeEquality

[<RequireQualifiedAccess>]
module Teq =

[<RequireQualifiedAccess>]
module Cong =

val domainOf<'domain1, 'domain2, 'range1, 'range2> :
Teq<'domain1 -> 'range1, 'domain2 -> 'range2> -> Teq<'domain1, 'domain2>
"""
5 changes: 4 additions & 1 deletion src/Fantomas/CodePrinter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1103,7 +1103,10 @@ and genVal astContext (Val (ats, px, ao, s, t, vi, isInline, _) as node) =
+> genericParams
+> addSpaceAfterGenericConstructBeforeColon
+> sepColon
+> ifElse (List.isNotEmpty namedArgs) (genTypeList astContext namedArgs) (genConstraints astContext t)
+> ifElse
(List.isNotEmpty namedArgs)
(autoNlnIfExpressionExceedsPageWidth (genTypeList astContext namedArgs))
(genConstraints astContext t)
+> unindent)
|> genTriviaFor ValSpfn_ range

Expand Down