Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update scalafmt-core to 3.8.0 #106

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Scala Steward: Reformat with scalafmt 3.8.0
6df2f1f7bffbc455329c35336848f3a311955dcd
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ fileOverride {

style = defaultWithAlign
maxColumn = 120
version = 3.5.9
version = 3.8.0
2 changes: 1 addition & 1 deletion benchmark/build.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
enablePlugins(JmhPlugin)
enablePlugins(JmhPlugin)
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
21 changes: 9 additions & 12 deletions macros/src/main/scala-3/io/github/metarank/cfor/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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
Expand Down Expand Up @@ -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.*

Expand All @@ -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.*

Expand Down Expand Up @@ -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.*

Expand Down
8 changes: 4 additions & 4 deletions macros/src/test/scala/io/github/metarank/cfor/CforTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ 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 incr: Int => Int = { v += 10; _ + 1 }
def body: Int => Unit = {
v += 100
x => {
Expand Down Expand Up @@ -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
Expand Down
Loading