diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 0000000..183a5dd --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,2 @@ +# Scala Steward: Reformat with scalafmt 3.10.4 +14bf6755d142fb0f31cd738bd42833e29d2ba79f diff --git a/.scalafmt.conf b/.scalafmt.conf index 1b8d920..4f195cf 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -7,4 +7,4 @@ fileOverride { style = defaultWithAlign maxColumn = 120 -version = 3.5.9 \ No newline at end of file +version = 3.10.4 \ No newline at end of file diff --git a/benchmark/build.sbt b/benchmark/build.sbt index 2c44dbc..bb17cb1 100644 --- a/benchmark/build.sbt +++ b/benchmark/build.sbt @@ -1 +1 @@ -enablePlugins(JmhPlugin) \ No newline at end of file +enablePlugins(JmhPlugin) diff --git a/macros/build.sbt b/macros/build.sbt index 88227c2..3262454 100644 --- a/macros/build.sbt +++ b/macros/build.sbt @@ -7,7 +7,7 @@ publishTo := sonatypePublishToBundle.value licenses := Seq("APL2" -> url("http://www.apache.org/licenses/LICENSE-2.0.txt")) homepage := Some(url("https://github.com/metarank/cfor")) -scmInfo := Some( +scmInfo := Some( ScmInfo( url("https://github.com/metarank/cfor"), "scm:git@github.com:metarank/cfor.git" diff --git a/macros/src/main/scala-2/io/github/metarank/cfor/Syntax.scala b/macros/src/main/scala-2/io/github/metarank/cfor/Syntax.scala index 878c44f..bbf1a0b 100644 --- a/macros/src/main/scala-2/io/github/metarank/cfor/Syntax.scala +++ b/macros/src/main/scala-2/io/github/metarank/cfor/Syntax.scala @@ -52,7 +52,7 @@ class InlineUtil[C <: Context with Singleton](val c: C) { } case tt: TypeTree if tt.original != null => - //super.transform(TypeTree().setOriginal(transform(tt.original))) + // super.transform(TypeTree().setOriginal(transform(tt.original))) super.transform(setOrig(c)(TypeTree(), transform(tt.original))) case _ => super.transform(tree) @@ -216,7 +216,7 @@ object Syntax { isLiteral(step) match { case Some(k) if k > 0 => strideUpUntil(i, j, k) case Some(k) if k < 0 => strideDownUntil(i, j, -k) - case Some(k) => + case Some(k) => c.error(c.enclosingPosition, "zero stride") q"()" case None => @@ -228,7 +228,7 @@ object Syntax { isLiteral(step) match { case Some(k) if k > 0 => strideUpTo(i, j, k) case Some(k) if k < 0 => strideDownTo(i, j, -k) - case Some(k) => + case Some(k) => c.error(c.enclosingPosition, "zero stride") q"()" case None => diff --git a/macros/src/main/scala-3/io/github/metarank/cfor/package.scala b/macros/src/main/scala-3/io/github/metarank/cfor/package.scala index 8ecdb98..d29c69f 100644 --- a/macros/src/main/scala-3/io/github/metarank/cfor/package.scala +++ b/macros/src/main/scala-3/io/github/metarank/cfor/package.scala @@ -5,7 +5,7 @@ import scala.collection.immutable.NumericRange type RangeLike = Range | NumericRange[Long] type RangeElem[X <: RangeLike] = X match - case Range => Int + case Range => Int case NumericRange[Long] => Long inline def cfor[A](inline init: A)(inline test: A => Boolean, inline next: A => A)(inline body: A => Unit): Unit = @@ -17,7 +17,6 @@ inline def cfor[A](inline array: Array[A])(body: A => Unit): Unit = inline def cfor[R <: RangeLike](inline r: R)(inline body: RangeElem[R] => Unit): Unit = ${ cforRangeMacroGen('r, 'body) } - //-------------------------------------------------------------------------- // // Code from below are based on file @@ -46,7 +45,7 @@ import scala.PartialFunction.cond import scala.quoted.* private def cforImpl[R: Type](init: Expr[R], test: Expr[R => Boolean], next: Expr[R => R], body: Expr[R => Unit])(using - Quotes + Quotes ): Expr[Unit] = import quotes.reflect.* @@ -61,7 +60,7 @@ private def cforImpl[R: Type](init: Expr[R], test: Expr[R => Boolean], next: Exp end cforImpl private def cforRangeMacroGen[R <: RangeLike: Type](r: Expr[R], body: Expr[RangeElem[R] => Unit])(using - quotes: Quotes + quotes: Quotes ): Expr[Unit] = import quotes.reflect.* @@ -139,14 +138,12 @@ private object RangeForImpl: end RangeForImpl - -/** - * Equivalent to `'{ val name: A => B = $rhs; ${in('name)} }`, except when `rhs` is a function literal, then equivalent - * to `in(rhs)`. - * - * This allows inlined function arguments to perform side-effects only once before their first evaluation, while still - * avoiding the creation of closures for function literal arguments. - */ +/** Equivalent to `'{ val name: A => B = $rhs; ${in('name)} }`, except when `rhs` is a function literal, then equivalent + * to `in(rhs)`. + * + * This allows inlined function arguments to perform side-effects only once before their first evaluation, while still + * avoiding the creation of closures for function literal arguments. + */ private def letFunc[A, B, C](using Quotes)(name: String, rhs: Expr[A => B])(in: Expr[A => B] => Expr[C]): Expr[C] = import quotes.reflect.* diff --git a/macros/src/test/scala/io/github/metarank/cfor/CforTest.scala b/macros/src/test/scala/io/github/metarank/cfor/CforTest.scala index 3ea771e..4c4af5e 100644 --- a/macros/src/test/scala/io/github/metarank/cfor/CforTest.scala +++ b/macros/src/test/scala/io/github/metarank/cfor/CforTest.scala @@ -49,11 +49,11 @@ class CforTest extends AnyFlatSpec with Matchers { } it should "functions with side effects function values in cfor" in { - val b = mutable.ArrayBuffer.empty[Int] - var v = 0 + val b = mutable.ArrayBuffer.empty[Int] + var v = 0 def test: Int => Boolean = { v += 1; _ < 3 } - def incr: Int => Int = { v += 10; _ + 1 } - def body: Int => Unit = { + def incr: Int => Int = { v += 10; _ + 1 } + def body: Int => Unit = { v += 100 x => { b += x @@ -144,7 +144,7 @@ class CforTest extends AnyFlatSpec with Matchers { it should "functions with side effects in cfor(arr)" in { var sum = 0 - var v = 0 + var v = 0 val arr = Array(0, 1, 2, 3, 4) cfor(arr) { v += 100