From 7633e6403d350afe551614f961e0da34b3468f47 Mon Sep 17 00:00:00 2001 From: Tobias Roeser Date: Sat, 16 Sep 2023 10:29:45 +0200 Subject: [PATCH] Backport Scala 2.13.12 support (#1377) Backport of #1375 Pull request: https://github.com/com-lihaoyi/Ammonite/pull/1377 --------- Co-authored-by: Alexandre Archambault --- .github/workflows/actions.yml | 4 +- .../ammonite/compiler/MakeReporter.scala | 0 .../ammonite/compiler/MakeReporter.scala | 45 +++++++++++++++++++ build.sc | 10 +++-- 4 files changed, 53 insertions(+), 6 deletions(-) rename amm/compiler/src/main/{scala-2.13.1+ => scala-2.13.1-2.13.11}/ammonite/compiler/MakeReporter.scala (100%) create mode 100644 amm/compiler/src/main/scala-2.13.12+/ammonite/compiler/MakeReporter.scala diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index fe640d0af..b62f83a3c 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -14,7 +14,7 @@ jobs: fail-fast: false matrix: java-version: [8, 11] - scala-version: [2.12.18, 2.13.11, 3.2.2] + scala-version: [2.12.18, 2.13.12, 3.2.2] runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -29,7 +29,7 @@ jobs: fail-fast: false matrix: java-version: [8, 11] - scala-version: [2.12.18, 2.13.11, 3.2.2] + scala-version: [2.12.18, 2.13.12, 3.2.2] runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 diff --git a/amm/compiler/src/main/scala-2.13.1+/ammonite/compiler/MakeReporter.scala b/amm/compiler/src/main/scala-2.13.1-2.13.11/ammonite/compiler/MakeReporter.scala similarity index 100% rename from amm/compiler/src/main/scala-2.13.1+/ammonite/compiler/MakeReporter.scala rename to amm/compiler/src/main/scala-2.13.1-2.13.11/ammonite/compiler/MakeReporter.scala diff --git a/amm/compiler/src/main/scala-2.13.12+/ammonite/compiler/MakeReporter.scala b/amm/compiler/src/main/scala-2.13.12+/ammonite/compiler/MakeReporter.scala new file mode 100644 index 000000000..02a864110 --- /dev/null +++ b/amm/compiler/src/main/scala-2.13.12+/ammonite/compiler/MakeReporter.scala @@ -0,0 +1,45 @@ +package ammonite.compiler + +import ammonite.util.Classpath + +import scala.reflect.internal.util.{CodeAction, Position} +import scala.reflect.io.FileZipArchive +import scala.tools.nsc +import scala.tools.nsc.classpath.{AggregateClassPath, ZipAndJarClassPathFactory} +import scala.tools.nsc.{Global, Settings} +import scala.tools.nsc.interactive.{InteractiveAnalyzer, Global => InteractiveGlobal} +import scala.tools.nsc.plugins.Plugin +import scala.tools.nsc.reporters.FilteringReporter +import scala.tools.nsc.typechecker.Analyzer + +object MakeReporter { + + type Reporter = scala.tools.nsc.reporters.Reporter + + def makeReporter(errorLogger: (Position, String) => Unit, + warningLogger: (Position, String) => Unit, + infoLogger: (Position, String) => Unit, + outerSettings: Settings): Reporter = + new FilteringReporter { + + override + def doReport(pos: scala.reflect.internal.util.Position, + msg: String, + severity: Severity, + actions: List[CodeAction]): Unit = + display(pos, msg, severity) + + def display(pos: Position, msg: String, severity: Severity) = + severity match{ + case ERROR => + Classpath.traceClasspathProblem(s"ERROR: $msg") + errorLogger(pos, msg) + case WARNING => + warningLogger(pos, msg) + case INFO => + infoLogger(pos, msg) + } + + def settings = outerSettings + } +} diff --git a/build.sc b/build.sc index 6c7ae68ce..1bd705768 100644 --- a/build.sc +++ b/build.sc @@ -46,7 +46,7 @@ val cross2_3Version = (scala3Ver: String) => val scala2_12Versions = Seq("2.12.8", "2.12.9", "2.12.10", "2.12.11", "2.12.12", "2.12.13", "2.12.14", "2.12.15", "2.12.16", "2.12.17", "2.12.18") -val scala2_13Versions = Seq("2.13.0", "2.13.1", "2.13.2", "2.13.3", "2.13.4", "2.13.5", "2.13.6", "2.13.7", "2.13.8", "2.13.9", "2.13.10", "2.13.11") +val scala2_13Versions = Seq("2.13.0", "2.13.1", "2.13.2", "2.13.3", "2.13.4", "2.13.5", "2.13.6", "2.13.7", "2.13.8", "2.13.9", "2.13.10", "2.13.11", "2.13.12") val scala30Versions = Seq("3.0.0", "3.0.1", "3.0.2") val scala31Versions = Seq("3.1.0", "3.1.1", "3.1.2", "3.1.3") val scala32Versions = Seq("3.2.0", "3.2.1", "3.2.2") @@ -79,7 +79,7 @@ val fastparseVersion = "2.3.0" val scalametaVersion = "4.8.5" object Deps { - val acyclic = ivy"com.lihaoyi:::acyclic:0.3.8" + val acyclic = ivy"com.lihaoyi:::acyclic:0.3.9" val bsp4j = ivy"ch.epfl.scala:bsp4j:${bspVersion}" val bcprovJdk15on = ivy"org.bouncycastle:bcprov-jdk15on:1.56" val cask = ivy"com.lihaoyi::cask:0.6.0" @@ -269,8 +269,10 @@ trait AmmInternalModule extends CrossSbtModule with Bloop.Module{ val extraDir3 = if (isScala2()) { val dir = - if (sv.startsWith("2.13.") && sv != "2.13.0") - millSourcePath / "src" / "main" / "scala-2.13.1+" + if (sv.startsWith("2.13.") && sv.stripPrefix("2.13.").toInt >= 1 && sv.stripPrefix("2.13.").toInt <= 11) + millSourcePath / "src" / "main" / "scala-2.13.1-2.13.11" + else if (sv.startsWith("2.13.") && sv.stripPrefix("2.13.").toInt >= 12) + millSourcePath / "src" / "main" / "scala-2.13.12+" else if (sv.startsWith("2.12.") && sv.stripPrefix("2.12.").toInt >= 13) millSourcePath / "src" / "main" / "scala-2.12.13+" else