From 5dc2a85a3491fac4767b18a5bde9acdb78264a38 Mon Sep 17 00:00:00 2001 From: Albert Meltzer <7529386+kitbellew@users.noreply.github.com> Date: Sat, 21 Dec 2024 08:05:40 -0800 Subject: [PATCH] Policy: restore implicit FileLine in Clause --- .../scala/org/scalafmt/internal/Policy.scala | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/scalafmt-core/shared/src/main/scala/org/scalafmt/internal/Policy.scala b/scalafmt-core/shared/src/main/scala/org/scalafmt/internal/Policy.scala index 82d652eae0..675364b857 100644 --- a/scalafmt-core/shared/src/main/scala/org/scalafmt/internal/Policy.scala +++ b/scalafmt-core/shared/src/main/scala/org/scalafmt/internal/Policy.scala @@ -109,26 +109,30 @@ object Policy { prefix: String, noDequeue: Boolean = false, rank: Int = 0, - )(f: Pf): Policy = apply(prefix, noDequeue, rank)(f) < exp + )(f: Pf)(implicit fl: FileLine): Policy = apply(prefix, noDequeue, rank)(f) < + exp def onLeft(exp: FT, prefix: String, noDequeue: Boolean = false, rank: Int = 0)( f: Pf, - ): Policy = apply(prefix, noDequeue, rank = rank)(f) <= exp + )(implicit fl: FileLine): Policy = apply(prefix, noDequeue, rank = rank)(f) <= + exp def onRight(exp: FT, prefix: String, noDequeue: Boolean = false, rank: Int = 0)( f: Pf, - ): Policy = apply(prefix, noDequeue, rank = rank)(f) >= exp + )(implicit fl: FileLine): Policy = apply(prefix, noDequeue, rank = rank)(f) >= + exp def afterRight( exp: FT, prefix: String, noDequeue: Boolean = false, rank: Int = 0, - )(f: Pf): Policy = apply(prefix, noDequeue, rank)(f) > exp + )(f: Pf)(implicit fl: FileLine): Policy = apply(prefix, noDequeue, rank)(f) > + exp def onlyFor(on: FT, prefix: String, noDequeue: Boolean = false, rank: Int = 0)( f: Seq[Split] => Seq[Split], - ): Policy = End <= on ==> + )(implicit fl: FileLine): Policy = End <= on ==> onRight(on, s"$prefix[${on.idx}]", noDequeue, rank) { case Decision(`on`, ss) => f(ss) } @@ -415,7 +419,7 @@ object Policy { val noDequeue: Boolean = false, val rank: Int = 0, desc: => String = "", - )(pred: Split => Split) + )(pred: Split => Split)(implicit fl: FileLine) extends Clause { private object PredicateDecision { def unapply(d: Decision): Option[Seq[Split]] = {