diff options
author | James Iry <jamesiry@gmail.com> | 2013-01-28 08:55:34 -0800 |
---|---|---|
committer | James Iry <jamesiry@gmail.com> | 2013-01-29 13:14:17 -0800 |
commit | 1de399d3c655807465c6369f77d08e57743e7eaa (patch) | |
tree | e967c0bf49de2ee368a137cf91308de623bc9d13 /src/compiler/scala/tools/nsc/typechecker/RefChecks.scala | |
parent | d4de6f4cc6c3f0f9d7810c6e9a10147a0406e3f5 (diff) | |
download | scala-1de399d3c655807465c6369f77d08e57743e7eaa.tar.gz scala-1de399d3c655807465c6369f77d08e57743e7eaa.tar.bz2 scala-1de399d3c655807465c6369f77d08e57743e7eaa.zip |
SI-6963 Add version to -Xmigration
Adds an optional version parameter to the -Xmigration compiler setting.
Doing -Xmigration without version number behaves as it used to by
dumping every possible migration warning.
This commit adds a ScalaVersion class (plus ancillary stuff), and a
ScalaVersionSetting.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/RefChecks.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/RefChecks.scala | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index 969bb8aceb..d1d70370d2 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -11,6 +11,9 @@ import scala.collection.{ mutable, immutable } import transform.InfoTransform import scala.collection.mutable.ListBuffer import scala.language.postfixOps +import scala.tools.nsc.settings.ScalaVersion +import scala.tools.nsc.settings.AnyScalaVersion +import scala.tools.nsc.settings.NoScalaVersion /** <p> * Post-attribution checking and transformation. @@ -1378,10 +1381,18 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans * indicating it has changed semantics between versions. */ private def checkMigration(sym: Symbol, pos: Position) = { - if (sym.hasMigrationAnnotation) - unit.warning(pos, "%s has changed semantics in version %s:\n%s".format( - sym.fullLocationString, sym.migrationVersion.get, sym.migrationMessage.get) - ) + if (sym.hasMigrationAnnotation) { + val changed = try + settings.Xmigration.value < ScalaVersion(sym.migrationVersion.get) + catch { + case e : NumberFormatException => + unit.warning(pos, s"${sym.fullLocationString} has an unparsable version number: ${e.getMessage()}") + // if we can't parse the format on the migration annotation just conservatively assume it changed + true + } + if (changed) + unit.warning(pos, s"${sym.fullLocationString} has changed semantics in version ${sym.migrationVersion.get}:\n${sym.migrationMessage.get}") + } } private def checkCompileTimeOnly(sym: Symbol, pos: Position) = { @@ -1587,7 +1598,7 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans * arbitrarily choose one as more important than the other. */ checkDeprecated(sym, tree.pos) - if (settings.Xmigration28.value) + if(settings.Xmigration.value != NoScalaVersion) checkMigration(sym, tree.pos) checkCompileTimeOnly(sym, tree.pos) |