From 5043c74325a0499dce3abfb767f941b9879a17d9 Mon Sep 17 00:00:00 2001 From: Albert Meltzer <7529386+kitbellew@users.noreply.github.com> Date: Thu, 26 Dec 2024 16:50:34 -0800 Subject: [PATCH] Use .isAny instead of multiple .is --- .../src/main/scala/org/scalafmt/internal/FormatOps.scala | 3 +-- .../src/main/scala/org/scalafmt/rewrite/RedundantBraces.scala | 2 +- .../src/main/scala/org/scalafmt/rewrite/SortModifiers.scala | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/scalafmt-core/shared/src/main/scala/org/scalafmt/internal/FormatOps.scala b/scalafmt-core/shared/src/main/scala/org/scalafmt/internal/FormatOps.scala index 2164a1439b..a581bb7bac 100644 --- a/scalafmt-core/shared/src/main/scala/org/scalafmt/internal/FormatOps.scala +++ b/scalafmt-core/shared/src/main/scala/org/scalafmt/internal/FormatOps.scala @@ -581,8 +581,7 @@ class FormatOps( if (cfg.assignmentOnly) isAfterAssignmentOp(false) else if (beforeLhs) assignBodyExpire.isEmpty else if ( - !app.singleArg - .exists(x => x.is[Term.Block] || x.is[Term.NewAnonymous]) && + !app.singleArg.exists(_.isAny[Term.Block, Term.NewAnonymous]) && isInfixTopLevelMatch(ft.meta.left.text, false) ) false else if (isInfixTopLevelMatch(app.op.value, true)) true 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 60531f2537..53c8d9f9d3 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 @@ -358,7 +358,7 @@ class RedundantBraces(implicit val ftoks: FormatTokens) } case _: Term.Interpolate => handleInterpolation case Importer(_, List(x)) - if !(x.is[Importee.Rename] || x.is[Importee.Unimport]) || + if !x.isAny[Importee.Rename, Importee.Unimport] || style.dialect.allowAsForImportRename && (ConvertToNewScala3Syntax.enabled || !x.tokens.exists(_.is[T.RightArrow])) => removeToken diff --git a/scalafmt-core/shared/src/main/scala/org/scalafmt/rewrite/SortModifiers.scala b/scalafmt-core/shared/src/main/scala/org/scalafmt/rewrite/SortModifiers.scala index 3b28b181f7..2dca536c07 100644 --- a/scalafmt-core/shared/src/main/scala/org/scalafmt/rewrite/SortModifiers.scala +++ b/scalafmt-core/shared/src/main/scala/org/scalafmt/rewrite/SortModifiers.scala @@ -39,8 +39,8 @@ class SortModifiers(implicit ctx: RewriteCtx) extends RewriteSession { case p: Term.Param => val start = p.pos.start sortMods(p.mods.filterNot { m => - m.is[Mod.ValParam] || m.is[Mod.VarParam] || m.is[Mod.Using] || - m.is[Mod.Erased] || TreeOps.noExplicitImplicit(start, false)(m) + m.isAny[Mod.ValParam, Mod.VarParam, Mod.Using, Mod.Erased] || + TreeOps.noExplicitImplicit(start, orElse = false)(m) }) case _ => }