From 4e7fd5ce080a42fb4c6eeba5f8a005bd973d6c8e Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Fri, 5 Mar 2010 06:01:19 +0000 Subject: 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. --- src/compiler/scala/tools/nsc/typechecker/RefChecks.scala | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/compiler/scala/tools/nsc/typechecker/RefChecks.scala') 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 -- cgit v1.2.3