diff --git a/build.sbt b/build.sbt index cfc1c4544..fcbd00fb6 100644 --- a/build.sbt +++ b/build.sbt @@ -162,20 +162,19 @@ 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, @@ -183,11 +182,14 @@ lazy val expressionCompiler = projectMatrix 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 @@ -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 _ => ??? } } diff --git a/modules/expression-compiler/src/main/scala-3.1+/dotty/tools/dotc/evaluation/SymUtils.scala b/modules/expression-compiler/src/main/scala-3.1.0-3.3.3/dotty/tools/dotc/evaluation/SymUtils.scala similarity index 100% rename from modules/expression-compiler/src/main/scala-3.1+/dotty/tools/dotc/evaluation/SymUtils.scala rename to modules/expression-compiler/src/main/scala-3.1.0-3.3.3/dotty/tools/dotc/evaluation/SymUtils.scala diff --git a/modules/expression-compiler/src/main/scala-3.4+/dotty/tools/dotc/evaluation/SymUtils.scala b/modules/expression-compiler/src/main/scala-3.3.4+/dotty/tools/dotc/evaluation/SymUtils.scala similarity index 100% rename from modules/expression-compiler/src/main/scala-3.4+/dotty/tools/dotc/evaluation/SymUtils.scala rename to modules/expression-compiler/src/main/scala-3.3.4+/dotty/tools/dotc/evaluation/SymUtils.scala diff --git a/modules/sbt-plugin/src/sbt-test/debug-session/scala-collection-compat/build.sbt b/modules/sbt-plugin/src/sbt-test/debug-session/scala-collection-compat/build.sbt index be280ebb6..1fe3db20b 100644 --- a/modules/sbt-plugin/src/sbt-test/debug-session/scala-collection-compat/build.sbt +++ b/modules/sbt-plugin/src/sbt-test/debug-session/scala-collection-compat/build.sbt @@ -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 diff --git a/modules/tests/src/test/scala/ch/epfl/scala/debugadapter/ScalaEvaluationTests.scala b/modules/tests/src/test/scala/ch/epfl/scala/debugadapter/ScalaEvaluationTests.scala index f15590f39..46f6a3bd3 100644 --- a/modules/tests/src/test/scala/ch/epfl/scala/debugadapter/ScalaEvaluationTests.scala +++ b/modules/tests/src/test/scala/ch/epfl/scala/debugadapter/ScalaEvaluationTests.scala @@ -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)) ) @@ -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 | @@ -1884,7 +1883,6 @@ 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 @@ -1892,7 +1890,6 @@ abstract class ScalaEvaluationTests(scalaVersion: ScalaVersion) extends DebugTes 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), @@ -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") { @@ -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), diff --git a/modules/tests/src/test/scala/ch/epfl/scala/debugadapter/internal/RuntimeEvaluatorTests.scala b/modules/tests/src/test/scala/ch/epfl/scala/debugadapter/internal/RuntimeEvaluatorTests.scala index 40cd32624..a048291ca 100644 --- a/modules/tests/src/test/scala/ch/epfl/scala/debugadapter/internal/RuntimeEvaluatorTests.scala +++ b/modules/tests/src/test/scala/ch/epfl/scala/debugadapter/internal/RuntimeEvaluatorTests.scala @@ -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") { @@ -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 @@ -1247,7 +1243,6 @@ 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 @@ -1255,7 +1250,6 @@ abstract class ScalaRuntimeEvaluatorTests(val scalaVersion: ScalaVersion) extend 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) ) } diff --git a/project/Dependencies.scala b/project/Dependencies.scala index ecc871d7f..0c78849ca 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -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" diff --git a/project/SemVer.scala b/project/SemVer.scala new file mode 100644 index 000000000..a326f1d72 --- /dev/null +++ b/project/SemVer.scala @@ -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) +}