Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RedundantBraces: don't remove parens in Init args #3545

Merged
merged 2 commits into from
May 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) => () })