Skip to content

Commit

Permalink
Write out generic type constraint in type definition. Fixes fsproject…
Browse files Browse the repository at this point in the history
  • Loading branch information
nojaf committed Jun 12, 2020
1 parent 11370c3 commit d9b3131
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/Fantomas.Tests/TypeDeclarationTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1345,3 +1345,18 @@ type Message =
{ [<JsonProperty("body")>]
Body: string }
"""

[<Test>]
let ``type constraint on type definition, 887`` () =
formatSourceString false """
type OuterType =
abstract Apply<'r>
: InnerType<'r>
-> 'r when 'r : comparison
""" { config with SpaceBeforeColon = true }
|> prepend newline
|> should equal """
type OuterType =
abstract Apply<'r> : InnerType<'r>
-> 'r when 'r : comparison
"""
1 change: 1 addition & 0 deletions src/Fantomas/CodePrinter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2605,6 +2605,7 @@ and genMemberDefn astContext node =
+> opt sepSpace ao genAccess -- sprintf "abstract %s" s
+> genTypeParamPostfix astContext tds tcs
+> sepColonX +> genTypeList astContext namedArgs -- genPropertyKind (not isFunctionProperty) mk
+> genConstraints astContext t

| md -> failwithf "Unexpected member definition: %O" md
|> genTrivia node.Range
Expand Down

0 comments on commit d9b3131

Please sign in to comment.