From acbdbb81213cea1477329ecc599b9aa04fbd4cf3 Mon Sep 17 00:00:00 2001 From: Alexandre Archambault Date: Wed, 19 Jun 2024 18:55:44 +0200 Subject: [PATCH] Update Scala to 3.4.2 (#1381) --- .github/workflows/ci.yml | 2 +- build.sc | 16 ++++++++++++++++ .../main/scala-3.3/almond/internals/Helper.scala | 10 ++++++++++ .../scala-3.4+/almond/internals/Helper.scala | 10 ++++++++++ .../internals/ScalaInterpreterCompletions.scala | 4 +--- .../main/scala/almond/integration/Tests.scala | 10 +++++++++- project/deps.sc | 3 ++- 7 files changed, 49 insertions(+), 6 deletions(-) create mode 100644 modules/scala/scala-interpreter/src/main/scala-3.3/almond/internals/Helper.scala create mode 100644 modules/scala/scala-interpreter/src/main/scala-3.4+/almond/internals/Helper.scala diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c46a48eb7..b9ad19d19 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,7 +40,7 @@ jobs: matrix: OS: [ubuntu-latest] JDK: [8] - SCALA: [2.12.18, 2.12.19, 2.13.13, 2.13.14, 3.3.3] + SCALA: [2.12.18, 2.12.19, 2.13.13, 2.13.14, 3.3.3, 3.4.2] include: - OS: windows-latest JDK: 8 diff --git a/build.sc b/build.sc index a3ae3df5a..56814a740 100644 --- a/build.sc +++ b/build.sc @@ -234,6 +234,9 @@ trait ScalaInterpreter extends Cross.Module[String] with AlmondModule with Bloop else Nil scala213Options } + def sources = T.sources { + super.sources() ++ CrossSources.extraSourcesDirs(scalaVersion(), millSourcePath) + } object test extends CrossSbtModuleTests with AlmondTestModule { def moduleDeps = { val rx = @@ -857,3 +860,16 @@ object dummy extends Module { ) } } + +object CrossSources { + def extraSourcesDirs(sv: String, millSourcePath: os.Path): Seq[PathRef] = { + val (maj, min) = sv.split('.') match { + case Array(maj0, min0, _*) if min0.nonEmpty && min0.forall(_.isDigit) => + (maj0, min0.toInt) + case _ => + sys.error(s"Malformed Scala version: $sv") + } + val baseDir = millSourcePath / "src" / "main" + (0 to min).map(min0 => PathRef(baseDir / s"scala-$maj.$min0+")) + } +} diff --git a/modules/scala/scala-interpreter/src/main/scala-3.3/almond/internals/Helper.scala b/modules/scala/scala-interpreter/src/main/scala-3.3/almond/internals/Helper.scala new file mode 100644 index 000000000..8708e0c83 --- /dev/null +++ b/modules/scala/scala-interpreter/src/main/scala-3.3/almond/internals/Helper.scala @@ -0,0 +1,10 @@ +package almond.internals + +import dotty.tools.dotc.CompilationUnit +import dotty.tools.dotc.util.SourceFile + +object Helper { + def nonSuspendableCompilationUnit(source: SourceFile): CompilationUnit = + new CompilationUnit(source): + override def isSuspendable: Boolean = false +} diff --git a/modules/scala/scala-interpreter/src/main/scala-3.4+/almond/internals/Helper.scala b/modules/scala/scala-interpreter/src/main/scala-3.4+/almond/internals/Helper.scala new file mode 100644 index 000000000..245d71162 --- /dev/null +++ b/modules/scala/scala-interpreter/src/main/scala-3.4+/almond/internals/Helper.scala @@ -0,0 +1,10 @@ +package almond.internals + +import dotty.tools.dotc.CompilationUnit +import dotty.tools.dotc.util.SourceFile + +object Helper { + def nonSuspendableCompilationUnit(source: SourceFile): CompilationUnit = + new CompilationUnit(source, null): + override def isSuspendable: Boolean = false +} diff --git a/modules/scala/scala-interpreter/src/main/scala-3/almond/internals/ScalaInterpreterCompletions.scala b/modules/scala/scala-interpreter/src/main/scala-3/almond/internals/ScalaInterpreterCompletions.scala index 5b8e7c45e..32610564c 100644 --- a/modules/scala/scala-interpreter/src/main/scala-3/almond/internals/ScalaInterpreterCompletions.scala +++ b/modules/scala/scala-interpreter/src/main/scala-3/almond/internals/ScalaInterpreterCompletions.scala @@ -196,9 +196,7 @@ object ScalaInterpreterCompletions { ) implicit val ctx: Context = run.runContext.withSource(sourceFile) - val unit = - new CompilationUnit(ctx.source): - override def isSuspendable: Boolean = false + val unit = Helper.nonSuspendableCompilationUnit(ctx.source) ctx .run .compileUnits(unit :: Nil, ctx) diff --git a/modules/scala/test-definitions/src/main/scala/almond/integration/Tests.scala b/modules/scala/test-definitions/src/main/scala/almond/integration/Tests.scala index 07d55abd6..08594842e 100644 --- a/modules/scala/test-definitions/src/main/scala/almond/integration/Tests.scala +++ b/modules/scala/test-definitions/src/main/scala/almond/integration/Tests.scala @@ -851,13 +851,21 @@ object Tests { | ^ |No warnings can be incurred under -Xfatal-warnings. |Compilation Failed""".stripMargin - else + else if ((0 to 3).exists(min => scalaVersion.startsWith(s"3.$min."))) // FIXME The line number is wrong here """-- Error: cmd2.sc:3:8 ---------------------------------------------------------- |3 |val n = getValue() | | ^^^^^^^^ | | method getValue in class Helper is deprecated since 0.1: foo |Compilation Failed""".stripMargin + else + // FIXME The line number is wrong here + """-- Warning: cmd2.sc:3:8 -------------------------------------------------------- + |3 |val n = getValue() + | | ^^^^^^^^ + | | method getValue in class Helper is deprecated since 0.1: foo + |No warnings can be incurred under -Werror (or -Xfatal-warnings) + |Compilation Failed""".stripMargin execute( """//> using option "-Xfatal-warnings" "-deprecation" diff --git a/project/deps.sc b/project/deps.sc index c79a68006..7511f9107 100644 --- a/project/deps.sc +++ b/project/deps.sc @@ -75,7 +75,7 @@ object Deps { } object ScalaVersions { - def scala3Latest = "3.3.3" + def scala3Latest = "3.4.2" def scala3Compat = "3.3.0" def scala213 = "2.13.14" def scala212 = "2.12.19" @@ -83,6 +83,7 @@ object ScalaVersions { val scala2Binaries = Seq(scala213, scala212) val all = Seq( scala3Latest, + "3.3.3", "3.3.2", "3.3.1", scala3Compat,