Skip to content

Commit

Permalink
Merge pull request #753 from adpi2/bump-scala-versions
Browse files Browse the repository at this point in the history
Bump Scala versions
  • Loading branch information
adpi2 authored Sep 5, 2024
2 parents 11ce5f2 + a8213e8 commit b48d57c
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 52 deletions.
38 changes: 20 additions & 18 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -162,32 +162,34 @@ lazy val expressionCompiler = projectMatrix
.customRow(true, Seq(scala34PlusAxis, VirtualAxis.jvm), p => p.dependsOn(tests3 % Test))
.settings(
name := "scala-expression-compiler",
crossScalaVersions ++= CrossVersion
.partialVersion(scalaVersion.value)
.collect {
crossScalaVersions ++= {
SemVer(scalaVersion.value) match {
// NOTE: Adding new handle for Scala version requires updating ./.github/workflows/release-expression-compiler.yml
// format: off
case (2, 12) => Seq("2.12.19", "2.12.18", "2.12.17", "2.12.16", "2.12.15", "2.12.14", "2.12.13")
case (2, 13) => Seq("2.13.14", "2.13.13", "2.13.12", "2.13.11", "2.13.10", "2.13.9", "2.13.8", "2.13.7", "2.13.6", "2.13.5", "2.13.4")
case (3, 0) => Seq("3.0.2", "3.0.1", "3.0.0")
case (3, 1 | 2 | 3) => Seq("3.3.3", "3.3.2", "3.3.1", "3.3.0", "3.2.2", "3.2.1", "3.2.0", "3.1.3", "3.1.2", "3.1.1", "3.1.0")
case (3, _) => Seq("3.5.1-RC1", "3.5.0-RC5", "3.4.2", "3.4.1", "3.4.0")
case (2, 12, _) => Seq("2.12.20", "2.12.19", "2.12.18", "2.12.17", "2.12.16", "2.12.15", "2.12.14", "2.12.13")
case (2, 13, _) => Seq("2.13.14", "2.13.13", "2.13.12", "2.13.11", "2.13.10", "2.13.9", "2.13.8", "2.13.7", "2.13.6", "2.13.5", "2.13.4")
case (3, 0, _) => Seq("3.0.2", "3.0.1", "3.0.0")
case (3, 1 | 2 | 3, _) => Seq("3.3.4-RC1", "3.3.3", "3.3.2", "3.3.1", "3.3.0", "3.2.2", "3.2.1", "3.2.0", "3.1.3", "3.1.2", "3.1.1", "3.1.0")
case (3, _, _) => Seq("3.5.1-RC2", "3.5.0", "3.4.3", "3.4.2", "3.4.1", "3.4.0")
case _ => Seq.empty
// format: on
}
.toSeq
.flatten,
},
crossScalaVersions := crossScalaVersions.value.distinct,
libraryDependencies ++= Seq(Dependencies.munit % Test) ++
onScalaVersion(scala212 = Some(Dependencies.scalaCollectionCompat), scala213 = None, scala3 = None).value,
crossTarget := target.value / s"scala-${scalaVersion.value}",
crossVersion := CrossVersion.full,
Compile / unmanagedSourceDirectories ++= {
val sourceDir = (Compile / sourceDirectory).value
CrossVersion.partialVersion(scalaVersion.value).collect {
case (3, 0) => sourceDir / s"scala-3.0"
case (3, 1 | 2 | 3) => sourceDir / s"scala-3.1+"
case (3, _) => sourceDir / s"scala-3.4+"
val fileNames = SemVer(scalaVersion.value) match {
case (3, 0, _) => Seq("scala-3.0")
case (3, 1 | 2 | 3, patch) if patch <= 3 => Seq("scala-3.1+", "scala-3.1.0-3.3.3")
case (3, 1 | 2 | 3, _) => Seq("scala-3.1+", "scala-3.3.4+")
case (3, _, _) => Seq("scala-3.4+", "scala-3.3.4+")
case _ => Seq.empty
}
fileNames.map(sourceDir / _)
},
Test / unmanagedSourceDirectories ++= {
val sourceDir = (Test / sourceDirectory).value
Expand Down Expand Up @@ -250,10 +252,10 @@ lazy val scala31PlusAxis = VirtualAxis.ScalaVersionAxis(Dependencies.scala31Plus
lazy val scala34PlusAxis = VirtualAxis.ScalaVersionAxis(Dependencies.scala34Plus, "34Plus")

def onScalaVersion[T](scala212: T, scala213: T, scala3: T) = Def.setting {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 12)) => scala212
case Some((2, 13)) => scala213
case Some((3, _)) => scala3
SemVer(scalaVersion.value) match {
case (2, 12, _) => scala212
case (2, 13, _) => scala213
case (3, _, _) => scala3
case _ => ???
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import ch.epfl.scala.debugadapter.testfmk._
import ch.epfl.scala.debugadapter.DebugConfig

val scalaCollectionCompat = inputKey[Unit]("Check the presence of scala-collection-compat")
val scalaV = "2.12.19"
val scalaV = "2.12.20"

def checkScalaCollectionCompat = Def.inputTask {
val uri = (Compile / startMainClassDebugSession).evaluated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,6 @@ abstract class ScalaEvaluationTests(scalaVersion: ScalaVersion) extends DebugTes
check(
Breakpoint(6),
DebugStepAssert.inParallel(Evaluation.success("n", 1), Evaluation.success("m1()", 9)),
if (isScala3 && scalaVersion < ScalaVersion.`3.5.0`) Breakpoint(9) else NoStep(),
Breakpoint(9),
DebugStepAssert.inParallel(Evaluation.success("n", 1), Evaluation.success("m1()", 9))
)
Expand Down Expand Up @@ -1855,7 +1854,7 @@ abstract class ScalaEvaluationTests(scalaVersion: ScalaVersion) extends DebugTes
check(Breakpoint(6), Evaluation.success("x\nx", "Hello"))
}

test("on for loops, generators and guards") {
test("loops, generators and guards") {
val source =
"""|package example
|
Expand Down Expand Up @@ -1884,15 +1883,13 @@ abstract class ScalaEvaluationTests(scalaVersion: ScalaVersion) extends DebugTes
Breakpoint(8),
DebugStepAssert.inParallel(Evaluation.success("list(0)", 1), Evaluation.success("x", 1)),
Breakpoint(9), // calling map
if (scalaVersion < ScalaVersion.`3.5.0`) Breakpoint(9) else NoStep(),
Evaluation.success("x + y", 2), // finally we are into the lifted lambda x + y
Breakpoint(8), // still in the same lifted lambda (the line position does not make any sense)
Breakpoint(9), // again in the lifted lambda
Breakpoint(8), // going out of the lifted lambda
Breakpoint(8), // regression in Scala 3.2.2
Breakpoint(9), // regression in Scala 3.2.2
Breakpoint(13), // calling withFilter
if (scalaVersion < ScalaVersion.`3.5.0`) Breakpoint(13) else NoStep(),
Evaluation.success("x", 1),
Breakpoint(15),
Evaluation.success("list(0)", 1),
Expand Down Expand Up @@ -2314,11 +2311,7 @@ abstract class ScalaEvaluationTests(scalaVersion: ScalaVersion) extends DebugTes
| b.m1()
|""".stripMargin
implicit val debuggee: TestingDebuggee = TestingDebuggee.mainClass(source, "example.Main", scalaVersion)
check(
if (isScala33) Breakpoint(8) else NoStep(), // Stops once in the constructor of B
Breakpoint(8),
Evaluation.success("x1 + x2 + x3", "x1x2x3")
)
check(Breakpoint(8), Evaluation.success("x1 + x2 + x3", "x1x2x3"))
}

test("brace-less syntax: evaluate in package") {
Expand Down Expand Up @@ -2574,8 +2567,6 @@ abstract class ScalaEvaluationTests(scalaVersion: ScalaVersion) extends DebugTes
implicit val debuggee: TestingDebuggee = TestingDebuggee.mainClass(source, "example.Main", scalaVersion)
check(
Breakpoint(12),
if (isScala33) Breakpoint(12) else NoStep(),
if (isScala33) Breakpoint(15) else NoStep(),
Breakpoint(20),
DebugStepAssert.inParallel(Evaluation.success("A.A1.a", 1), Evaluation.success("A.A2.a", 2)),
Breakpoint(15),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1151,11 +1151,7 @@ abstract class ScalaRuntimeEvaluatorTests(val scalaVersion: ScalaVersion) extend
|}
|""".stripMargin
implicit val debuggee: TestingDebuggee = TestingDebuggee.mainClass(source, "example.Main", scalaVersion)
check(
Breakpoint(6),
if (scalaVersion < ScalaVersion.`3.5.0`) Breakpoint(6) else NoStep(),
Evaluation.success("n", 1)
)
check(Breakpoint(6), Evaluation.success("n", 1))
}

test("evaluate captured local variable shadowing captured variable") {
Expand Down Expand Up @@ -1222,7 +1218,7 @@ abstract class ScalaRuntimeEvaluatorTests(val scalaVersion: ScalaVersion) extend
)
}

test("evaluate on for loops, generators and guards") {
test("loops, generators and guards") {
assume(scalaVersion.isScala3)
val source =
"""|package example
Expand All @@ -1247,15 +1243,13 @@ abstract class ScalaRuntimeEvaluatorTests(val scalaVersion: ScalaVersion) extend
Breakpoint(8),
Evaluation.success("x", 1),
Breakpoint(9), // calling map
if (scalaVersion < ScalaVersion.`3.5.0`) Breakpoint(9) else NoStep(),
Evaluation.success("y", 1), // finally we are into the lifted lambda x + y
Breakpoint(8), // still in the same lifted lambda (the line position does not make any sense)
Breakpoint(9), // again in the lifted lambda
Breakpoint(8), // going out of the lifted lambda
Breakpoint(8), // regression in Scala 3.2.2
Breakpoint(9), // regression in Scala 3.2.2
Breakpoint(13), // calling withFilter
if (scalaVersion < ScalaVersion.`3.5.0`) Breakpoint(13) else NoStep(),
Evaluation.success("x", 1)
)
}
Expand Down
25 changes: 11 additions & 14 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,34 @@ import sbt._

object Dependencies {
val scalaEnvVersion = Option(System.getenv("SCALA_VERSION"))
val scala212 = scalaEnvVersion.filter(isScala212).getOrElse("2.12.19")
val scala212 = scalaEnvVersion.filter(isScala212).getOrElse("2.12.20")
val scala213 = scalaEnvVersion.filter(isScala213).getOrElse("2.13.14")
val scala30 = scalaEnvVersion.filter(isScala30).getOrElse("3.0.2")
val scala31Plus = scalaEnvVersion.filter(isScala33).getOrElse("3.3.3")
val scala34Plus = scalaEnvVersion.filter(isScala34).getOrElse("3.5.1-RC1")
val scala31Plus = scalaEnvVersion.filter(isScala31Plus).getOrElse("3.3.4-RC1")
val scala34Plus = scalaEnvVersion.filter(isScala34Plus).getOrElse("3.5.1-RC2")
val asmVersion = "9.7"
val coursierVersion = "2.1.10"

def isScala212(version: String): Boolean = version.startsWith("2.12")
def isScala213(version: String): Boolean = version.startsWith("2.13")
def isScala30(version: String): Boolean = version.startsWith("3.0")
def isScala33(version: String): Boolean =
version.startsWith("3.1") || version.startsWith("3.2") || version.startsWith("3.3")
def isScala34(version: String): Boolean = version.startsWith("3") && !isScala30(version) && !isScala33(version)
def isScala31Plus(version: String): Boolean = SemVer.matches(version) { case (3, 1 | 2 | 3, _) => true }
def isScala34Plus(version: String): Boolean = SemVer.matches(version) { case (3, min, _) => min >= 4 }

val asm = "org.ow2.asm" % "asm" % asmVersion
val asmUtil = "org.ow2.asm" % "asm-util" % asmVersion

def scalaCompiler(scalaVersion: String): ModuleID = {
CrossVersion.partialVersion(scalaVersion) match {
case Some((3, _)) => "org.scala-lang" %% "scala3-compiler" % scalaVersion
def scalaCompiler(scalaVersion: String): ModuleID =
SemVer(scalaVersion) match {
case (3, _, _) => "org.scala-lang" %% "scala3-compiler" % scalaVersion
case _ => "org.scala-lang" % "scala-compiler" % scalaVersion
}
}

def scalaReflect(scalaVersion: String): ModuleID = {
CrossVersion.partialVersion(scalaVersion) match {
case Some((3, _)) => "org.scala-lang" % "scala-reflect" % scala213
def scalaReflect(scalaVersion: String): ModuleID =
SemVer(scalaVersion) match {
case (3, _, _) => "org.scala-lang" % "scala-reflect" % scala213
case _ => "org.scala-lang" % "scala-reflect" % scalaVersion
}
}

val scalaParallelCollection = "org.scala-lang.modules" %% "scala-parallel-collections" % "1.0.4"
val scalaCollectionCompat = "org.scala-lang.modules" %% "scala-collection-compat" % "2.12.0"
Expand Down
7 changes: 7 additions & 0 deletions project/SemVer.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
object SemVer {
def apply(version: String): (Int, Int, Int) =
"(\\d+)\\.(\\d+)\\.(\\d+)(?:-.*)?".r.unapplySeq(version).map(xs => (xs(0).toInt, xs(1).toInt, xs(2).toInt)).get

def matches(version: String)(f: PartialFunction[(Int, Int, Int), Boolean]): Boolean =
f.lift(SemVer(version)).getOrElse(false)
}

0 comments on commit b48d57c

Please sign in to comment.