summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2010-03-05 06:01:19 +0000
committerPaul Phillips <paulp@improving.org>2010-03-05 06:01:19 +0000
commit4e7fd5ce080a42fb4c6eeba5f8a005bd973d6c8e (patch)
treea44c5ed902c1abc93303c9cdfb162d2c9b97e364 /src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
parent98c87462f7ffcc14dc4fbab9df586a200b77428b (diff)
downloadscala-4e7fd5ce080a42fb4c6eeba5f8a005bd973d6c8e.tar.gz
scala-4e7fd5ce080a42fb4c6eeba5f8a005bd973d6c8e.tar.bz2
scala-4e7fd5ce080a42fb4c6eeba5f8a005bd973d6c8e.zip
Added -Xmigration option and @migration annotat...
Added -Xmigration option and @migration annotation. At present it will warn about the following changes from 2.7 to 2.8: Stack iterator order reversed mutable.Set.map returns a Set and thus discards duplicates A case 'x @ Pattern' matches differently than 'Pattern' Review by odersky.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/RefChecks.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/RefChecks.scala16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
index 55500c7f17..28eebdc033 100644
--- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
@@ -927,6 +927,13 @@ abstract class RefChecks extends InfoTransform {
unit.deprecationWarning(pos, msg)
}
}
+ /** Similar to deprecation: check if the symbol is marked with @migration
+ * indicating it has changed semantics between versions.
+ */
+ private def checkMigration(sym: Symbol, pos: Position) =
+ for (msg <- sym.migrationMessage)
+ unit.warning(pos, "%s%s has changed semantics:\n %s".format(sym, sym.locationString, msg))
+
/** Check that a deprecated val or def does not override a
* concrete, non-deprecated method. If it does, then
* deprecation is meaningless.
@@ -1027,7 +1034,16 @@ abstract class RefChecks extends InfoTransform {
private def transformSelect(tree: Select): Tree = {
val Select(qual, name) = tree
val sym = tree.symbol
+
+ /** Note: if a symbol has both @deprecated and @migration annotations and both
+ * warnings are enabled, only the first one checked here will be emitted.
+ * I assume that's a consequence of some code trying to avoid noise by suppressing
+ * warnings after the first, but I think it'd be better if we didn't have to
+ * arbitrarily choose one as more important than the other.
+ */
checkDeprecated(sym, tree.pos)
+ if (settings.Xmigration28.value)
+ checkMigration(sym, tree.pos)
if (currentClass != sym.owner && (sym hasFlag LOCAL)) {
var o = currentClass