From 5ad937aee877f1093b53b114fce931c71ea39554 Mon Sep 17 00:00:00 2001 From: Albert Meltzer <7529386+kitbellew@users.noreply.github.com> Date: Mon, 30 May 2022 22:25:52 -0700 Subject: [PATCH] Scalameta: upgrade to v4.5.9 Fixes parsing of additional anonymous functions. --- project/Dependencies.scala | 2 +- .../src/main/scala/org/scalafmt/rewrite/AvoidInfix.scala | 8 +++----- .../src/test/resources/rewrite/RedundantParens.stat | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/project/Dependencies.scala b/project/Dependencies.scala index df9219f22e..2e594a6169 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -6,7 +6,7 @@ import org.portablescala.sbtplatformdeps.PlatformDepsPlugin.autoImport._ object Dependencies { val metaconfigV = "0.10.0" - val scalametaV = "4.5.8" + val scalametaV = "4.5.9" val scalacheckV = "1.15.4" val coursier = "1.0.3" val munitV = "0.7.29" diff --git a/scalafmt-core/shared/src/main/scala/org/scalafmt/rewrite/AvoidInfix.scala b/scalafmt-core/shared/src/main/scala/org/scalafmt/rewrite/AvoidInfix.scala index 8559703017..61f0c374bc 100644 --- a/scalafmt-core/shared/src/main/scala/org/scalafmt/rewrite/AvoidInfix.scala +++ b/scalafmt-core/shared/src/main/scala/org/scalafmt/rewrite/AvoidInfix.scala @@ -2,7 +2,7 @@ package org.scalafmt.rewrite import scala.annotation.tailrec import scala.meta._ -import scala.meta.internal.trees.PlaceholderChecks +import scala.meta.internal.trees.PlaceholderChecks.hasPlaceholder import org.scalafmt.config.FilterMatcher import org.scalafmt.config.RewriteSettings @@ -103,12 +103,10 @@ class AvoidInfix(implicit ctx: RewriteCtx) extends RewriteSession { val op = ai.op.value InfixApp.isLeftAssoc(op) && matcher.matches(op) && (ai.args match { case arg :: Nil if !isWrapped(arg) => - !ctx.style.rewrite.allowInfixPlaceholderArg && - PlaceholderChecks.isPlaceholder(arg) || - !PlaceholderChecks.hasPlaceholder(arg) + !hasPlaceholder(arg, ctx.style.rewrite.allowInfixPlaceholderArg) case _ => true }) && (ai.lhs match { - case lhs: Term.ApplyInfix if PlaceholderChecks.hasPlaceholder(lhs) => + case lhs: Term.ApplyInfix if hasPlaceholder(lhs, true) => isWrapped(lhs) || checkMatchingInfix(lhs) case _ => true }) diff --git a/scalafmt-tests/src/test/resources/rewrite/RedundantParens.stat b/scalafmt-tests/src/test/resources/rewrite/RedundantParens.stat index 20b210fd96..d07a4eff7e 100644 --- a/scalafmt-tests/src/test/resources/rewrite/RedundantParens.stat +++ b/scalafmt-tests/src/test/resources/rewrite/RedundantParens.stat @@ -1297,5 +1297,5 @@ object a { } >>> object a { - Box.apply(_: Int, _: String).tupled + (Box.apply(_: Int, _: String)).tupled }