From 1a05b8d392e5d2eef36fc0ea4fd1e43b10cebd36 Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Mon, 29 Jul 2019 13:52:46 +0200 Subject: Future-proof Dotty-version checks (#663) Prepare for 3.x, like in zinc itself: https://github.com/sbt/zinc/pull/678 --- scalalib/api/src/ZincWorkerApi.scala | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/scalalib/api/src/ZincWorkerApi.scala b/scalalib/api/src/ZincWorkerApi.scala index 0480e8e6..418b18c6 100644 --- a/scalalib/api/src/ZincWorkerApi.scala +++ b/scalalib/api/src/ZincWorkerApi.scala @@ -47,7 +47,8 @@ case class CompilationResult(analysisFile: os.Path, classes: PathRef) object Util { def isDotty(scalaVersion: String) = - scalaVersion.startsWith("0.") + scalaVersion.startsWith("0.") || + scalaVersion.startsWith("3.") def grepJar(classPath: Agg[os.Path], name: String, version: String, sources: Boolean = false) = { @@ -65,23 +66,23 @@ object Util { private val ReleaseVersion = raw"""(\d+)\.(\d+)\.(\d+)""".r private val MinorSnapshotVersion = raw"""(\d+)\.(\d+)\.([1-9]\d*)-SNAPSHOT""".r - private val DottyVersion = raw"""0\.(\d+)\.(\d+).*""".r - private val DottyNightlyVersion = raw"""0\.(\d+)\.(\d+)-bin-(.*)-NIGHTLY""".r + private val DottyVersion = raw"""(0|3)\.(\d+)\.(\d+).*""".r + private val DottyNightlyVersion = raw"""(0|3)\.(\d+)\.(\d+)-bin-(.*)-NIGHTLY""".r private val TypelevelVersion = raw"""(\d+)\.(\d+)\.(\d+)-bin-typelevel.*""".r def scalaBinaryVersion(scalaVersion: String) = scalaVersion match { case ReleaseVersion(major, minor, _) => s"$major.$minor" case MinorSnapshotVersion(major, minor, _) => s"$major.$minor" - case DottyVersion(minor, _) => s"0.$minor" + case DottyVersion("0", minor, _) => s"0.$minor" case TypelevelVersion(major, minor, _) => s"$major.$minor" case _ => scalaVersion } /** @return true if the compiler bridge can be downloaded as an already compiled jar */ def isBinaryBridgeAvailable(scalaVersion: String) = scalaVersion match { - case DottyNightlyVersion(minor, _, _) => minor.toInt >= 14 // 0.14.0-bin or more (not 0.13.0-bin) - case DottyVersion(minor, _) => minor.toInt >= 13 // 0.13.0-RC1 or more + case DottyNightlyVersion(major, minor, _, _) => major.toInt > 0 || minor.toInt >= 14 // 0.14.0-bin or more (not 0.13.0-bin) + case DottyVersion(major, minor, _) => major.toInt > 0 || minor.toInt >= 13 // 0.13.0-RC1 or more case _ => false } } -- cgit v1.2.3