Skip to content

Commit f6b8c84

Browse files
authored
Merge pull request #1733 from bjaglin/211sources
fail hard when running against 2.11 sources
2 parents 56fb6de + cae181b commit f6b8c84

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

scalafix-cli/src/main/scala/scalafix/internal/interfaces/ScalafixArgumentsImpl.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,10 @@ final case class ScalafixArgumentsImpl(args: Args = Args.default)
251251
copy(args = args.copy(scalacOptions = options.asScala.toList))
252252

253253
override def withScalaVersion(version: String): ScalafixArguments = {
254+
if (version.startsWith("2.11"))
255+
throw new ScalafixMainArgsException(
256+
"Scala 2.11 is no longer supported; the final version supporting it is Scalafix 0.10.4"
257+
)
254258
ScalaVersion
255259
.from(version) match {
256260
case Success(value) => copy(args = args.copy(scalaVersion = value))

scalafix-cli/src/main/scala/scalafix/internal/interfaces/ScalafixImpl.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ final class ScalafixImpl extends Scalafix {
2424
override def supportedScalaVersions(): Array[String] =
2525
Versions.supportedScalaVersions.toArray
2626
override def scala211(): String =
27-
throw new java.lang.UnsupportedOperationException()
27+
throw new java.lang.UnsupportedOperationException(
28+
"Scala 2.11 is no longer supported; the final version supporting it is Scalafix 0.10.4"
29+
)
2830
override def scala212(): String =
2931
Versions.scala212
3032
override def scala213(): String =

scalafix-tests/unit/src/test/scala/scalafix/tests/interfaces/ScalafixArgumentsSuite.scala

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import java.nio.file.Paths
77
import java.util.Collections
88

99
import scala.collection.JavaConverters._
10-
import scala.util.Failure
1110
import scala.util.Try
1211

1312
import scala.meta.internal.io.FileIO
@@ -507,14 +506,15 @@ class ScalafixArgumentsSuite extends AnyFunSuite with DiffAssertions {
507506

508507
test("withScalaVersion: non-parsable scala version") {
509508
val run = Try(api.withScalaVersion("213"))
510-
assert(run.isFailure)
511-
run match {
512-
case Failure(exception) =>
513-
assert(
514-
exception.getMessage == "Failed to parse the Scala version"
515-
)
516-
case _ => ()
517-
}
509+
val expectedErrorMessage = "Failed to parse the Scala version"
510+
assert(run.failed.toOption.map(_.getMessage) == Some(expectedErrorMessage))
511+
}
512+
513+
test("Scala 2.11 is no longer supported") {
514+
val run = Try(api.withScalaVersion("2.11.12"))
515+
val expectedErrorMessage =
516+
"Scala 2.11 is no longer supported; the final version supporting it is Scalafix 0.10.4"
517+
assert(run.failed.toOption.map(_.getMessage) == Some(expectedErrorMessage))
518518
}
519519

520520
def removeUnsuedRule(): SemanticRule = {

0 commit comments

Comments
 (0)