diff --git a/scalafmt-core/shared/src/main/scala/org/scalafmt/rewrite/RedundantBraces.scala b/scalafmt-core/shared/src/main/scala/org/scalafmt/rewrite/RedundantBraces.scala index c8b52d9ce7..148cd3e5fd 100644 --- a/scalafmt-core/shared/src/main/scala/org/scalafmt/rewrite/RedundantBraces.scala +++ b/scalafmt-core/shared/src/main/scala/org/scalafmt/rewrite/RedundantBraces.scala @@ -130,6 +130,10 @@ case object RedundantBraces extends Rewrite { !isProcedureSyntax(d) && !disqualifiedByUnit + case p: Term.Function + if ctx.style.activeForEdition_2019_11 && isBlockFunction(p) => + settings.methodBodies + case _ => settings.generalExpressions && exactlyOneStatement && diff --git a/scalafmt-tests/src/test/resources/rewrite/RedundantBraces.stat b/scalafmt-tests/src/test/resources/rewrite/RedundantBraces.stat index 897c52ffd4..ecbcfe4eba 100644 --- a/scalafmt-tests/src/test/resources/rewrite/RedundantBraces.stat +++ b/scalafmt-tests/src/test/resources/rewrite/RedundantBraces.stat @@ -154,3 +154,57 @@ object a { def x: Int = // comment 2 } +<<< fixes nested block in multi-line lambda 1 +object a { + method { x => { // 1 + 2 + 3 + 4 + } + } +} +>>> +object a { + method { x => // 1 + 2 + 3 + 4 + } +} +<<< fixes nested block in multi-line lambda 2 +object a { + method { x => + { // 1 + 2 + 3 + 4 + } + } +} +>>> +object a { + method { x => + // 1 + 2 + 3 + 4 + } +} +<<< doesn't touch block in multi-line paren lambda +object a { + method ( x => + { + 2 + 3 + 4 + } + ) +} +>>> +object a { + method(x => { + 2 + 3 + 4 + }) +}