Skip to content

Commit 8a3d729

Browse files
committed
Nits
1 parent a44924d commit 8a3d729

File tree

3 files changed

+17
-18
lines changed

3 files changed

+17
-18
lines changed

modules/build/src/main/scala/scala/build/errors/NetworkUnaccessibleScalaVersionError.scala

Lines changed: 0 additions & 6 deletions
This file was deleted.

modules/build/src/main/scala/scala/build/options/BuildOptions.scala

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package scala.build.options
22
import coursier.cache.{ArchiveCache, FileCache}
3-
import coursier.core.Version
3+
import coursier.core.{Version, Versions => CoreVersions}
44
import coursier.jvm.{JavaHome, JvmCache, JvmIndex}
55
import coursier.util.{Artifact, Task}
66
import coursier.{Module, Versions}
@@ -386,13 +386,25 @@ final case class BuildOptions(
386386
(scalaVersion, scalaBinaryVersion)
387387
}
388388

389+
private def latestScalaVersionFrom(
390+
versions: CoreVersions,
391+
desc: String
392+
): Either[scala.build.errors.ScalaVersionError, String] =
393+
versions.latest(coursier.core.Latest.Release) match {
394+
case Some(versionString) => Right(versionString)
395+
case None =>
396+
val msg =
397+
s"Unable to find matching version for $desc in available version: ${versions.available.mkString(", ")}. " +
398+
"This error may indicate a network or other problem accessing repository."
399+
Left(new ScalaVersionError(msg))
400+
}
401+
389402
/** @return
390403
* Either a BuildException or the calculated (ScalaVersion, ScalaBinaryVersion) tuple
391404
*/
392405
private def computeLatestScalaThreeNightlyVersions(): Either[BuildException, (String, String)] =
393406
either {
394407
import coursier.Versions
395-
import coursier.core.Latest
396408
import coursier._
397409

398410
val moduleVersion: Either[ScalaVersionError, String] = {
@@ -403,10 +415,7 @@ final case class BuildOptions(
403415
.result()
404416
.unsafeRun()(finalCache.ec)
405417
}
406-
res.versions.latest(Latest.Release) match {
407-
case Some(versionString) => Right(versionString)
408-
case None => Left(new NetworkUnaccessibleScalaVersionError(None))
409-
}
418+
latestScalaVersionFrom(res.versions, "latest Scala 3 nightly build")
410419
}
411420

412421
val scalaVersion = value(moduleVersion)
@@ -420,7 +429,6 @@ final case class BuildOptions(
420429
private def computeLatestScalaTwoNightlyVersions(): Either[BuildException, (String, String)] =
421430
either {
422431
import coursier.Versions
423-
import coursier.core.Latest
424432
import coursier._
425433

426434
val moduleVersion: Either[ScalaVersionError, String] = {
@@ -432,10 +440,7 @@ final case class BuildOptions(
432440
.result()
433441
.unsafeRun()(finalCache.ec)
434442
}
435-
res.versions.latest(Latest.Release) match {
436-
case Some(versionString) => Right(versionString)
437-
case None => Left(new NetworkUnaccessibleScalaVersionError(None))
438-
}
443+
latestScalaVersionFrom(res.versions, "latest Scala 2 nightly build")
439444
}
440445

441446
val scalaVersion = value(moduleVersion)

website/docs/commands/compile.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ For compiling with an specific nightly build, you have the full version for:
8585
scala-cli Hello.scala -S 2.13.9-bin-4505094
8686
```
8787

88-
For adding this inside scala files through the using directives syntax, you write:
88+
For adding this inside scala files with [using directives](../guides/using-directives.md), use:
8989

9090
```scala
9191
//> using scala "2.nightly"

0 commit comments

Comments
 (0)