From 1b299555b93e7e908e480beb8ff8dc853242a7dd Mon Sep 17 00:00:00 2001 From: nojaf Date: Fri, 26 Mar 2021 20:27:34 +0100 Subject: [PATCH] genTrivia for SynExpr.TypeApp. Fixes #1543. --- src/Fantomas.Tests/CompilerDirectivesTests.fs | 31 +++++++++++++++++++ src/Fantomas/CodePrinter.fs | 1 + 2 files changed, 32 insertions(+) diff --git a/src/Fantomas.Tests/CompilerDirectivesTests.fs b/src/Fantomas.Tests/CompilerDirectivesTests.fs index a4335b049b..25066927e8 100644 --- a/src/Fantomas.Tests/CompilerDirectivesTests.fs +++ b/src/Fantomas.Tests/CompilerDirectivesTests.fs @@ -2414,3 +2414,34 @@ let tcrefObjTy, enclosingDeclaredTypars, renaming, objTy = FreshenTyconRef m rigid tcref declaredTyconTypars #endif """ + +[] +let ``defines as trivia for SynExpr.TypeApp, 1543`` () = + formatSourceString + false + """ +let inputFileFlagsFsiBase (_tcConfigB: TcConfigBuilder) = +#if NETSTANDARD + [ CompilerOption("usesdkrefs", tagNone, OptionSwitch (SetUseSdkSwitch _tcConfigB), None, Some (FSComp.SR.useSdkRefs())) ] +#else + List.empty +#endif +""" + config + |> prepend newline + |> should + equal + """ +let inputFileFlagsFsiBase (_tcConfigB: TcConfigBuilder) = +#if NETSTANDARD + [ CompilerOption( + "usesdkrefs", + tagNone, + OptionSwitch(SetUseSdkSwitch _tcConfigB), + None, + Some(FSComp.SR.useSdkRefs ()) + ) ] +#else + List.empty +#endif +""" diff --git a/src/Fantomas/CodePrinter.fs b/src/Fantomas/CodePrinter.fs index 79f78cf25a..25ed60a679 100644 --- a/src/Fantomas/CodePrinter.fs +++ b/src/Fantomas/CodePrinter.fs @@ -2706,6 +2706,7 @@ and genExpr astContext synExpr ctx = | SynExpr.ObjExpr _ -> genTriviaFor SynExpr_ObjExpr synExpr.Range | SynExpr.JoinIn _ -> genTriviaFor SynExpr_JoinIn synExpr.Range | SynExpr.Do _ -> genTriviaFor SynExpr_Do synExpr.Range + | SynExpr.TypeApp _ -> genTriviaFor SynExpr_TypeApp synExpr.Range | _ -> id) expr ctx