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..79cffe8e9b 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,7 @@ 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 cd9420c10d..9311c0bafd 100644 --- a/scalafmt-tests/src/test/resources/rewrite/RedundantBraces.stat +++ b/scalafmt-tests/src/test/resources/rewrite/RedundantBraces.stat @@ -1389,6 +1389,4 @@ object A: <<< ONLY #3540 object Bar extends Foo[(Int, String)]({ case (i, s) => () }) >>> -test does not parse -object Bar extends Foo[(Int, String)] { case (i, s) => () } - ^ +object Bar extends Foo[(Int, String)]({ case (i, s) => () })