Skip to content

Commit

Permalink
Merge pull request #563 from lwronski/scala-version
Browse files Browse the repository at this point in the history
For -S 3.x input use latest release from 3.x versions
  • Loading branch information
romanowski authored Jan 24, 2022
2 parents 2c8add7 + 5768906 commit 6612583
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -284,15 +284,17 @@ final case class BuildOptions(
sv match {
case Some(sv0) =>
val prefix = if (sv0.endsWith(".")) sv0 else sv0 + "."
val matchingVersions = allVersions.filter(_.startsWith(prefix))
val matchingVersions = allVersions.filter(_.startsWith(prefix)).map(Version(_))
if (matchingVersions.isEmpty)
Left(new InvalidBinaryScalaVersionError(sv0))
else {
val validMaxVersions = maxSupportedScalaVersions
.filter(_.repr.startsWith(prefix))
val validMatchingVersions = matchingVersions
.map(Version(_))
.filter(v => validMaxVersions.exists(v <= _))
val validMatchingVersions = {
val filtered = matchingVersions.filter(v => validMaxVersions.exists(v <= _))
if (filtered.isEmpty) matchingVersions
else filtered
}
if (validMatchingVersions.isEmpty)
Left(new UnsupportedScalaVersionError(sv0))
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ class BuildOptionsTests extends munit.FunSuite {
Some("2.12") -> defaultScala212Version,
Some("2") -> defaultScala213Version,
Some("2.13.2") -> "2.13.2",
Some("3.0.1") -> "3.0.1"
Some("3.0.1") -> "3.0.1",
Some("3.0") -> "3.0.2"
)

for ((prefix, expectedScalaVersion) <- expectedScalaVersions)
Expand All @@ -61,6 +62,7 @@ class BuildOptionsTests extends munit.FunSuite {

val expectedScalaConfVersions = Seq(
Some("3") -> "3.0.1",
Some("3.0") -> "3.0.1",
None -> "3.0.1",
Some("2.13") -> "2.13.4",
Some("2.12") -> "2.12.13",
Expand Down

0 comments on commit 6612583

Please sign in to comment.