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 dc9fb75987..f8eba86fa3 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 @@ -568,10 +568,10 @@ class FormatOps( case t => t } def isOldTopLevel(child: Tree) = child.parent.exists { - case _: Term.Block | _: Term.If | _: Term.While | _: Source => true + case _: Term.If | _: Term.While | _: Source => true case fun: Term.FunctionTerm => isBlockFunction(fun) case t: Case => t.pat.eq(child) || t.body.eq(child) - case SingleArgInBraces(_, arg, _) => child eq arg + case SingleArgInBraces.OrBlock(_, arg, _) => child eq arg case _ => false } def isAloneEnclosed(child: Tree) = child.parent.exists { diff --git a/scalafmt-tests/src/test/resources/rewrite/RedundantBraces.stat b/scalafmt-tests/src/test/resources/rewrite/RedundantBraces.stat index 15742248ba..31d401a6b7 100644 --- a/scalafmt-tests/src/test/resources/rewrite/RedundantBraces.stat +++ b/scalafmt-tests/src/test/resources/rewrite/RedundantBraces.stat @@ -1917,11 +1917,10 @@ object a { } } >>> -Idempotency violated -=> Diff (- obtained, + expected) - t.className != "scala/Console$" && -- // console accesses DynamicVariable, let's discard it too -- !t.className.startsWith("scala/util/DynamicVariable") -+ // console accesses DynamicVariable, let's discard it too -+ !t.className.startsWith("scala/util/DynamicVariable") - } +object a { + val standardFilter: MethodCallTrace => Boolean = t => + // ignore all calls to Console trigger by printing + t.className != "scala/Console$" && + // console accesses DynamicVariable, let's discard it too + !t.className.startsWith("scala/util/DynamicVariable") +}