Skip to content

Commit b48d57c

Browse files
authored
Merge pull request #753 from adpi2/bump-scala-versions
Bump Scala versions
2 parents 11ce5f2 + a8213e8 commit b48d57c

File tree

8 files changed

+43
-52
lines changed

8 files changed

+43
-52
lines changed

build.sbt

+20-18
Original file line numberDiff line numberDiff line change
@@ -162,32 +162,34 @@ lazy val expressionCompiler = projectMatrix
162162
.customRow(true, Seq(scala34PlusAxis, VirtualAxis.jvm), p => p.dependsOn(tests3 % Test))
163163
.settings(
164164
name := "scala-expression-compiler",
165-
crossScalaVersions ++= CrossVersion
166-
.partialVersion(scalaVersion.value)
167-
.collect {
165+
crossScalaVersions ++= {
166+
SemVer(scalaVersion.value) match {
168167
// NOTE: Adding new handle for Scala version requires updating ./.github/workflows/release-expression-compiler.yml
169168
// format: off
170-
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")
171-
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")
172-
case (3, 0) => Seq("3.0.2", "3.0.1", "3.0.0")
173-
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")
174-
case (3, _) => Seq("3.5.1-RC1", "3.5.0-RC5", "3.4.2", "3.4.1", "3.4.0")
169+
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")
170+
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")
171+
case (3, 0, _) => Seq("3.0.2", "3.0.1", "3.0.0")
172+
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")
173+
case (3, _, _) => Seq("3.5.1-RC2", "3.5.0", "3.4.3", "3.4.2", "3.4.1", "3.4.0")
174+
case _ => Seq.empty
175175
// format: on
176176
}
177-
.toSeq
178-
.flatten,
177+
},
179178
crossScalaVersions := crossScalaVersions.value.distinct,
180179
libraryDependencies ++= Seq(Dependencies.munit % Test) ++
181180
onScalaVersion(scala212 = Some(Dependencies.scalaCollectionCompat), scala213 = None, scala3 = None).value,
182181
crossTarget := target.value / s"scala-${scalaVersion.value}",
183182
crossVersion := CrossVersion.full,
184183
Compile / unmanagedSourceDirectories ++= {
185184
val sourceDir = (Compile / sourceDirectory).value
186-
CrossVersion.partialVersion(scalaVersion.value).collect {
187-
case (3, 0) => sourceDir / s"scala-3.0"
188-
case (3, 1 | 2 | 3) => sourceDir / s"scala-3.1+"
189-
case (3, _) => sourceDir / s"scala-3.4+"
185+
val fileNames = SemVer(scalaVersion.value) match {
186+
case (3, 0, _) => Seq("scala-3.0")
187+
case (3, 1 | 2 | 3, patch) if patch <= 3 => Seq("scala-3.1+", "scala-3.1.0-3.3.3")
188+
case (3, 1 | 2 | 3, _) => Seq("scala-3.1+", "scala-3.3.4+")
189+
case (3, _, _) => Seq("scala-3.4+", "scala-3.3.4+")
190+
case _ => Seq.empty
190191
}
192+
fileNames.map(sourceDir / _)
191193
},
192194
Test / unmanagedSourceDirectories ++= {
193195
val sourceDir = (Test / sourceDirectory).value
@@ -250,10 +252,10 @@ lazy val scala31PlusAxis = VirtualAxis.ScalaVersionAxis(Dependencies.scala31Plus
250252
lazy val scala34PlusAxis = VirtualAxis.ScalaVersionAxis(Dependencies.scala34Plus, "34Plus")
251253

252254
def onScalaVersion[T](scala212: T, scala213: T, scala3: T) = Def.setting {
253-
CrossVersion.partialVersion(scalaVersion.value) match {
254-
case Some((2, 12)) => scala212
255-
case Some((2, 13)) => scala213
256-
case Some((3, _)) => scala3
255+
SemVer(scalaVersion.value) match {
256+
case (2, 12, _) => scala212
257+
case (2, 13, _) => scala213
258+
case (3, _, _) => scala3
257259
case _ => ???
258260
}
259261
}

modules/sbt-plugin/src/sbt-test/debug-session/scala-collection-compat/build.sbt

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import ch.epfl.scala.debugadapter.testfmk._
22
import ch.epfl.scala.debugadapter.DebugConfig
33

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

77
def checkScalaCollectionCompat = Def.inputTask {
88
val uri = (Compile / startMainClassDebugSession).evaluated

modules/tests/src/test/scala/ch/epfl/scala/debugadapter/ScalaEvaluationTests.scala

+2-11
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,6 @@ abstract class ScalaEvaluationTests(scalaVersion: ScalaVersion) extends DebugTes
673673
check(
674674
Breakpoint(6),
675675
DebugStepAssert.inParallel(Evaluation.success("n", 1), Evaluation.success("m1()", 9)),
676-
if (isScala3 && scalaVersion < ScalaVersion.`3.5.0`) Breakpoint(9) else NoStep(),
677676
Breakpoint(9),
678677
DebugStepAssert.inParallel(Evaluation.success("n", 1), Evaluation.success("m1()", 9))
679678
)
@@ -1855,7 +1854,7 @@ abstract class ScalaEvaluationTests(scalaVersion: ScalaVersion) extends DebugTes
18551854
check(Breakpoint(6), Evaluation.success("x\nx", "Hello"))
18561855
}
18571856

1858-
test("on for loops, generators and guards") {
1857+
test("loops, generators and guards") {
18591858
val source =
18601859
"""|package example
18611860
|
@@ -1884,15 +1883,13 @@ abstract class ScalaEvaluationTests(scalaVersion: ScalaVersion) extends DebugTes
18841883
Breakpoint(8),
18851884
DebugStepAssert.inParallel(Evaluation.success("list(0)", 1), Evaluation.success("x", 1)),
18861885
Breakpoint(9), // calling map
1887-
if (scalaVersion < ScalaVersion.`3.5.0`) Breakpoint(9) else NoStep(),
18881886
Evaluation.success("x + y", 2), // finally we are into the lifted lambda x + y
18891887
Breakpoint(8), // still in the same lifted lambda (the line position does not make any sense)
18901888
Breakpoint(9), // again in the lifted lambda
18911889
Breakpoint(8), // going out of the lifted lambda
18921890
Breakpoint(8), // regression in Scala 3.2.2
18931891
Breakpoint(9), // regression in Scala 3.2.2
18941892
Breakpoint(13), // calling withFilter
1895-
if (scalaVersion < ScalaVersion.`3.5.0`) Breakpoint(13) else NoStep(),
18961893
Evaluation.success("x", 1),
18971894
Breakpoint(15),
18981895
Evaluation.success("list(0)", 1),
@@ -2314,11 +2311,7 @@ abstract class ScalaEvaluationTests(scalaVersion: ScalaVersion) extends DebugTes
23142311
| b.m1()
23152312
|""".stripMargin
23162313
implicit val debuggee: TestingDebuggee = TestingDebuggee.mainClass(source, "example.Main", scalaVersion)
2317-
check(
2318-
if (isScala33) Breakpoint(8) else NoStep(), // Stops once in the constructor of B
2319-
Breakpoint(8),
2320-
Evaluation.success("x1 + x2 + x3", "x1x2x3")
2321-
)
2314+
check(Breakpoint(8), Evaluation.success("x1 + x2 + x3", "x1x2x3"))
23222315
}
23232316

23242317
test("brace-less syntax: evaluate in package") {
@@ -2574,8 +2567,6 @@ abstract class ScalaEvaluationTests(scalaVersion: ScalaVersion) extends DebugTes
25742567
implicit val debuggee: TestingDebuggee = TestingDebuggee.mainClass(source, "example.Main", scalaVersion)
25752568
check(
25762569
Breakpoint(12),
2577-
if (isScala33) Breakpoint(12) else NoStep(),
2578-
if (isScala33) Breakpoint(15) else NoStep(),
25792570
Breakpoint(20),
25802571
DebugStepAssert.inParallel(Evaluation.success("A.A1.a", 1), Evaluation.success("A.A2.a", 2)),
25812572
Breakpoint(15),

modules/tests/src/test/scala/ch/epfl/scala/debugadapter/internal/RuntimeEvaluatorTests.scala

+2-8
Original file line numberDiff line numberDiff line change
@@ -1151,11 +1151,7 @@ abstract class ScalaRuntimeEvaluatorTests(val scalaVersion: ScalaVersion) extend
11511151
|}
11521152
|""".stripMargin
11531153
implicit val debuggee: TestingDebuggee = TestingDebuggee.mainClass(source, "example.Main", scalaVersion)
1154-
check(
1155-
Breakpoint(6),
1156-
if (scalaVersion < ScalaVersion.`3.5.0`) Breakpoint(6) else NoStep(),
1157-
Evaluation.success("n", 1)
1158-
)
1154+
check(Breakpoint(6), Evaluation.success("n", 1))
11591155
}
11601156

11611157
test("evaluate captured local variable shadowing captured variable") {
@@ -1222,7 +1218,7 @@ abstract class ScalaRuntimeEvaluatorTests(val scalaVersion: ScalaVersion) extend
12221218
)
12231219
}
12241220

1225-
test("evaluate on for loops, generators and guards") {
1221+
test("loops, generators and guards") {
12261222
assume(scalaVersion.isScala3)
12271223
val source =
12281224
"""|package example
@@ -1247,15 +1243,13 @@ abstract class ScalaRuntimeEvaluatorTests(val scalaVersion: ScalaVersion) extend
12471243
Breakpoint(8),
12481244
Evaluation.success("x", 1),
12491245
Breakpoint(9), // calling map
1250-
if (scalaVersion < ScalaVersion.`3.5.0`) Breakpoint(9) else NoStep(),
12511246
Evaluation.success("y", 1), // finally we are into the lifted lambda x + y
12521247
Breakpoint(8), // still in the same lifted lambda (the line position does not make any sense)
12531248
Breakpoint(9), // again in the lifted lambda
12541249
Breakpoint(8), // going out of the lifted lambda
12551250
Breakpoint(8), // regression in Scala 3.2.2
12561251
Breakpoint(9), // regression in Scala 3.2.2
12571252
Breakpoint(13), // calling withFilter
1258-
if (scalaVersion < ScalaVersion.`3.5.0`) Breakpoint(13) else NoStep(),
12591253
Evaluation.success("x", 1)
12601254
)
12611255
}

project/Dependencies.scala

+11-14
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,34 @@ import sbt._
22

33
object Dependencies {
44
val scalaEnvVersion = Option(System.getenv("SCALA_VERSION"))
5-
val scala212 = scalaEnvVersion.filter(isScala212).getOrElse("2.12.19")
5+
val scala212 = scalaEnvVersion.filter(isScala212).getOrElse("2.12.20")
66
val scala213 = scalaEnvVersion.filter(isScala213).getOrElse("2.13.14")
77
val scala30 = scalaEnvVersion.filter(isScala30).getOrElse("3.0.2")
8-
val scala31Plus = scalaEnvVersion.filter(isScala33).getOrElse("3.3.3")
9-
val scala34Plus = scalaEnvVersion.filter(isScala34).getOrElse("3.5.1-RC1")
8+
val scala31Plus = scalaEnvVersion.filter(isScala31Plus).getOrElse("3.3.4-RC1")
9+
val scala34Plus = scalaEnvVersion.filter(isScala34Plus).getOrElse("3.5.1-RC2")
1010
val asmVersion = "9.7"
1111
val coursierVersion = "2.1.10"
1212

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

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

23-
def scalaCompiler(scalaVersion: String): ModuleID = {
24-
CrossVersion.partialVersion(scalaVersion) match {
25-
case Some((3, _)) => "org.scala-lang" %% "scala3-compiler" % scalaVersion
22+
def scalaCompiler(scalaVersion: String): ModuleID =
23+
SemVer(scalaVersion) match {
24+
case (3, _, _) => "org.scala-lang" %% "scala3-compiler" % scalaVersion
2625
case _ => "org.scala-lang" % "scala-compiler" % scalaVersion
2726
}
28-
}
2927

30-
def scalaReflect(scalaVersion: String): ModuleID = {
31-
CrossVersion.partialVersion(scalaVersion) match {
32-
case Some((3, _)) => "org.scala-lang" % "scala-reflect" % scala213
28+
def scalaReflect(scalaVersion: String): ModuleID =
29+
SemVer(scalaVersion) match {
30+
case (3, _, _) => "org.scala-lang" % "scala-reflect" % scala213
3331
case _ => "org.scala-lang" % "scala-reflect" % scalaVersion
3432
}
35-
}
3633

3734
val scalaParallelCollection = "org.scala-lang.modules" %% "scala-parallel-collections" % "1.0.4"
3835
val scalaCollectionCompat = "org.scala-lang.modules" %% "scala-collection-compat" % "2.12.0"

project/SemVer.scala

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
object SemVer {
2+
def apply(version: String): (Int, Int, Int) =
3+
"(\\d+)\\.(\\d+)\\.(\\d+)(?:-.*)?".r.unapplySeq(version).map(xs => (xs(0).toInt, xs(1).toInt, xs(2).toInt)).get
4+
5+
def matches(version: String)(f: PartialFunction[(Int, Int, Int), Boolean]): Boolean =
6+
f.lift(SemVer(version)).getOrElse(false)
7+
}

0 commit comments

Comments
 (0)