From 320dbb3066383a841bd4b9a5500eabc7a199bac3 Mon Sep 17 00:00:00 2001 From: nojaf Date: Tue, 20 Jun 2023 13:05:25 +0200 Subject: [PATCH] Use inline keyword from GetSetMember trivia for MemberDefnPropertyGetSetNode. --- CHANGELOG.md | 5 +++++ src/Fantomas.Core.Tests/ClassTests.fs | 25 +++++++++++++++++++++++++ src/Fantomas.Core/ASTTransformer.fs | 6 +++--- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 801e0594b2..d37d7ebd67 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## [6.0.8] - 2023-06-20 + +### Fixed +* Inline keyword is missing in property [#2908](https://github.com/fsprojects/fantomas/issues/2908) + ## [6.0.7] - 2023-06-20 ### Fixed diff --git a/src/Fantomas.Core.Tests/ClassTests.fs b/src/Fantomas.Core.Tests/ClassTests.fs index 2ceea45a13..b3460a0c07 100644 --- a/src/Fantomas.Core.Tests/ClassTests.fs +++ b/src/Fantomas.Core.Tests/ClassTests.fs @@ -1330,3 +1330,28 @@ type X() = member private this.Y with set _ = () """ + +[] +let ``inline keyword on property, 2908`` () = + formatSourceString + false + """ +module Meh + +type Foo = + member inline this.Item + with get (i:int,j: char) : string = "" + and set (i:int,j: char) (x:string) = printfn "%i %c" i j +""" + config + |> prepend newline + |> should + equal + """ +module Meh + +type Foo = + member inline this.Item + with get (i: int, j: char): string = "" + and set (i: int, j: char) (x: string) = printfn "%i %c" i j +""" diff --git a/src/Fantomas.Core/ASTTransformer.fs b/src/Fantomas.Core/ASTTransformer.fs index f90bb8a0de..3981690302 100644 --- a/src/Fantomas.Core/ASTTransformer.fs +++ b/src/Fantomas.Core/ASTTransformer.fs @@ -2768,11 +2768,11 @@ let mkMemberDefn (creationAide: CreationAide) (md: SynMemberDefn) = attributes = ats xmlDoc = px headPat = SynPat.LongIdent(longDotId = memberName; accessibility = visGet) - trivia = { LeadingKeyword = lk - InlineKeyword = inlineKw }) as getBinding), + trivia = { LeadingKeyword = lk }) as getBinding), Some(SynBinding(headPat = SynPat.LongIdent(accessibility = visSet)) as setBinding), _, - { GetKeyword = Some getKeyword + { InlineKeyword = inlineKw + GetKeyword = Some getKeyword SetKeyword = Some setKeyword WithKeyword = withKeyword AndKeyword = andKeyword }) ->