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 e426c33f76..959c32870c 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 @@ -114,7 +114,8 @@ class RedundantBraces(ftoks: FormatTokens) extends FormatTokensRewrite.Rule { // single-arg apply of a partial function // a({ case b => c; d }) change to a { case b => c; d } def lpPartialFunction = rtOwner match { - case ta @ Term.ArgClause(arg :: Nil, _) => + case ta @ Term.ArgClause(arg :: Nil, _) + if !ta.parent.exists(_.is[Init]) => getOpeningParen(ta).map { lp => val ko = lp.ne(rt) || getBlockNestedPartialFunction(arg).isEmpty if (ko) null else removeToken diff --git a/scalafmt-tests/src/test/resources/rewrite/RedundantBraces.stat b/scalafmt-tests/src/test/resources/rewrite/RedundantBraces.stat index 5d7f7e521d..ef43893387 100644 --- a/scalafmt-tests/src/test/resources/rewrite/RedundantBraces.stat +++ b/scalafmt-tests/src/test/resources/rewrite/RedundantBraces.stat @@ -1386,3 +1386,7 @@ object A: case s: String => s case _ => ae.toString }.toList +<<< #3540 +object Bar extends Foo[(Int, String)]({ case (i, s) => () }) +>>> +object Bar extends Foo[(Int, String)]({ case (i, s) => () })