Skip to content

Commit

Permalink
RedundantBraces: don't remove parens in Init args
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed May 22, 2023
1 parent aae721e commit f872241
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) => () })

0 comments on commit f872241

Please sign in to comment.