Skip to content

Commit

Permalink
Revert multiline alternative for prefix types. (#2582)
Browse files Browse the repository at this point in the history
  • Loading branch information
nojaf committed Oct 14, 2022
1 parent 5646703 commit 8f39a43
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 31 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## [5.1.0-alpha-007] - 2022-10-14

### Changed
* Revert multiline alternative for prefix types. [#2582](https://github.com/fsprojects/fantomas/pull/2582)

## [5.1.0-alpha-006] - 2022-10-14

### Changed
Expand Down
6 changes: 2 additions & 4 deletions src/Fantomas.Core.Tests/ClassTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1248,10 +1248,8 @@ module rec Xterm
[<AllowNullLiteral>]
type Terminal =
abstract onKey:
IEvent<
{| key: string
domEvent: KeyboardEvent |}
> with get, set
IEvent<{| key: string
domEvent: KeyboardEvent |}> with get, set
abstract onLineFeed: IEvent<unit> with get, set
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -421,10 +421,10 @@ let ``multiline abstract member without constraints, 2175`` () =
type FuseSortFunctionItem =
abstract Item:
key: string ->
U2<
{| ``$``: string |},
ResizeArray<{| ``$``: string; idx: float |}>
> with get, set
U2<{| ``$``: string |}, ResizeArray<{| ``$``:
string
idx:
float |}>> with get, set
abstract X: int
"""
11 changes: 3 additions & 8 deletions src/Fantomas.Core.Tests/SignatureTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1606,14 +1606,9 @@ namespace Foo
type Bar =
member Hello :
thing :
XLongLongLongLongLongLongLongLong<
bool -> 'a,
bool -> 'b,
bool -> 'c,
bool -> 'd,
bool -> ('e -> 'f) -> 'g,
('h -> 'i) -> 'j
> *
XLongLongLongLongLongLongLongLong<bool -> 'a, bool -> 'b, bool -> 'c, bool -> 'd, bool -> ('e -> 'f) -> 'g, ('h
-> 'i)
-> 'j> *
item : int list ->
LongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLong
"""
Expand Down
59 changes: 52 additions & 7 deletions src/Fantomas.Core.Tests/TypeAnnotationTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,56 @@ type X =
equal
"""
type X =
Teq<
int,
list int,
System.DateTime array,
//
int
>
Teq<int, list int, System.DateTime array,
//
int>
"""

[<Test>]
let ``multiline app type`` () =
formatSourceString
false
"""
type CancellableTaskResultBuilderBase with
[<NoEagerConstraintApplication>]
static member inline BindDynamic< ^TaskLike, 'TResult1, 'TResult2, ^Awaiter, 'TOverall, 'Error
when ^TaskLike: (member GetAwaiter: unit -> ^Awaiter)
and ^Awaiter :> ICriticalNotifyCompletion
and ^Awaiter: (member get_IsCompleted: unit -> bool)
and ^Awaiter: (member GetResult: unit -> Result<'TResult1, 'Error>)>
(
sm:
byref<
ResumableStateMachine<
CancellableTaskResultStateMachineData<'TOverall, 'Error>
>
>,
task: CancellationToken -> ^TaskLike,
continuation:
('TResult1 -> CancellableTaskResultCode<'TOverall, 'Error, 'TResult2>)
) : bool = true
"""
{ config with MaxLineLength = 80 }
|> prepend newline
|> should
equal
"""
type CancellableTaskResultBuilderBase with
[<NoEagerConstraintApplication>]
static member inline BindDynamic< ^TaskLike, 'TResult1, 'TResult2, ^Awaiter, 'TOverall, 'Error
when ^TaskLike: (member GetAwaiter: unit -> ^Awaiter)
and ^Awaiter :> ICriticalNotifyCompletion
and ^Awaiter: (member get_IsCompleted: unit -> bool)
and ^Awaiter: (member GetResult: unit -> Result<'TResult1, 'Error>)>
(
sm:
byref<ResumableStateMachine<CancellableTaskResultStateMachineData<'TOverall, 'Error>>>,
task: CancellationToken -> ^TaskLike,
continuation:
('TResult1
-> CancellableTaskResultCode<'TOverall, 'Error, 'TResult2>)
) : bool =
true
"""
6 changes: 2 additions & 4 deletions src/Fantomas.Core.Tests/TypeDeclarationTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2874,10 +2874,8 @@ and [<CustomEquality ; NoComparison>] Bar<'context, 'a> =
(fun inner ->
if inner then
let bv =
unbox<Foo<
'innerContextLongLongLong,
'bb -> 'b
>>
unbox<Foo<'innerContextLongLongLong, 'bb
-> 'b>>
bf
this.InnerEquals af bf cont
Expand Down
5 changes: 1 addition & 4 deletions src/Fantomas.Core/CodePrinter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3691,12 +3691,9 @@ and genPrefixTypes
+> genTriviaForOption greaterNodeType greaterRange !- " >")
ctx
| t :: _ ->
let shortTs = col sepComma ts genType
let longTs = indentSepNlnUnindent (col (sepComma +> sepNln) ts genType) +> sepNln

(genTriviaForOption lessNodeType lessRange !- "<"
+> addSpaceIfSynTypeStaticConstantHasAtSignBeforeString t
+> expressionFitsOnRestOfLine shortTs longTs
+> col sepComma ts genType
+> addSpaceIfSynTypeStaticConstantHasAtSignBeforeString t
+> genTriviaForOption greaterNodeType greaterRange !- ">")
ctx
Expand Down

0 comments on commit 8f39a43

Please sign in to comment.