Skip to content

Commit

Permalink
RedudantParens: generalize unary-literal check
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Jul 26, 2024
1 parent b1b2b49 commit 13ea8cc
Showing 1 changed file with 1 addition and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,7 @@ class RedundantParens(implicit val ftoks: FormatTokens)
private def okToReplaceOther(
t: Tree,
)(implicit style: ScalafmtConfig): Boolean = t match {
case _: Lit => !t.parent.exists(_.is[Term.Ref]) ||
!t.tokens.headOption.exists(_.is[Token.Ident]) // unary
case _: Lit => t.tokens.length == 1 || !t.parent.exists(_.is[Term.Ref])
case _: Term.ApplyUnary => !t.parent.exists(_.is[Term.Ref])
case _: Member.Apply | _: Term.Interpolate | _: Term.PartialFunction => true
case t: Term.Select => ftoks.tokenBefore(t.name).left.is[Token.Dot]
Expand Down

0 comments on commit 13ea8cc

Please sign in to comment.