|
13 | 13 | package scala.tools.nsc |
14 | 14 | package settings |
15 | 15 |
|
16 | | -import scala.tools.nsc.settings.StandardScalaSettings.{AllTargetVersions, DefaultTargetVersion, SupportedTargetVersions} |
| 16 | +import scala.tools.nsc.settings.StandardScalaSettings._ |
17 | 17 | import scala.tools.util.PathResolver.Defaults |
18 | 18 | import scala.util.Properties.{isJavaAtLeast, javaSpecVersion} |
19 | 19 |
|
@@ -71,15 +71,17 @@ trait StandardScalaSettings { _: MutableSettings => |
71 | 71 | if (releaseValue.map(_.toInt < setting.value.toInt).getOrElse(false)) |
72 | 72 | errorFn("-release cannot be less than -target") |
73 | 73 | if (!setting.deprecationMessage.isDefined) |
74 | | - if (SupportedTargetVersions.contains(setting.value)) |
75 | | - setting.withDeprecationMessage("Use -release instead to compile against the correct platform API.") |
76 | | - else { |
| 74 | + if (setting.value.toInt > MaxSupportedTargetVersion) { |
| 75 | + setting.withDeprecationMessage(s"Scala 2.12 cannot emit valid class files for targets newer than $MaxSupportedTargetVersion (this is possible with Scala 2.13). Use -release to compile against a specific platform API version.") |
| 76 | + setting.value = DefaultTargetVersion |
| 77 | + } else if (setting.value.toInt < MinSupportedTargetVersion) { |
77 | 78 | setting.withDeprecationMessage(s"${setting.name}:${setting.value} is deprecated, forcing use of $DefaultTargetVersion") |
78 | | - setting.value = DefaultTargetVersion // triggers this hook |
| 79 | + setting.value = DefaultTargetVersion |
79 | 80 | } |
80 | 81 | } |
81 | 82 | .withAbbreviation("--target") |
82 | | - def targetValue: String = releaseValue.getOrElse(target.value) |
| 83 | + // Unlike 2.13, don't use `releaseValue.getOrElse(target.value)`, because 2.12 doesn't have a fix for scala-dev#408 |
| 84 | + def targetValue: String = target.value |
83 | 85 | val unchecked = BooleanSetting ("-unchecked", "Enable additional warnings where generated code depends on assumptions. See also -Wconf.") withAbbreviation "--unchecked" withPostSetHook { s => |
84 | 86 | if (s.value) Wconf.tryToSet(List(s"cat=unchecked:w")) |
85 | 87 | else Wconf.tryToSet(List(s"cat=unchecked:s")) |
@@ -115,9 +117,9 @@ object StandardScalaSettings { |
115 | 117 | case SpecificScalaVersion(major, _, _, _) => major |
116 | 118 | case _ => 19 |
117 | 119 | } |
| 120 | + val MaxSupportedTargetVersion = 8 |
118 | 121 | val DefaultTargetVersion = "8" |
119 | 122 |
|
120 | 123 | private val AllTargetVersions = (MinTargetVersion to MaxTargetVersion).map(_.toString).toList |
121 | | - val SupportedTargetVersions: List[String] = (MinSupportedTargetVersion to MaxTargetVersion).map(_.toString).toList |
122 | 124 | val AllPermissibleTargetValues: List[String] = AllTargetVersions.flatMap(v => v :: s"jvm-1.$v" :: s"jvm-$v" :: s"1.$v" :: Nil) |
123 | 125 | } |
0 commit comments