summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
diff options
context:
space:
mode:
authorSimon Ochsenreither <simon@ochsenreither.de>2012-07-31 01:02:07 +0200
committerJason Zaugg <jzaugg@gmail.com>2012-09-10 22:57:21 +0200
commite3b0c7abbf637dacce7bcd7b69d5655820e8e714 (patch)
tree392819cf24113b893c1622b5ecc80605bd34b3d6 /src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
parentadf2d3632b07eef4fc2303aef994e66584a73f49 (diff)
downloadscala-e3b0c7abbf637dacce7bcd7b69d5655820e8e714.tar.gz
scala-e3b0c7abbf637dacce7bcd7b69d5655820e8e714.tar.bz2
scala-e3b0c7abbf637dacce7bcd7b69d5655820e8e714.zip
SI-6162 Adds @deprecatedInheritance/@deprecatedOverriding
These annotations are meant to warn from inheriting a class or from overriding a member, due to the reasons given in `msg`. The naming and placement of the methods is in line with @deprecated and @deprecatedName.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/RefChecks.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/RefChecks.scala11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
index 166bb2d18c..919250c562 100644
--- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
@@ -430,6 +430,7 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R
overrideError("cannot override a macro")
} else {
checkOverrideTypes()
+ checkOverrideDeprecated()
if (settings.warnNullaryOverride.value) {
if (other.paramss.isEmpty && !member.paramss.isEmpty) {
unit.warning(member.pos, "non-nullary method overrides nullary method")
@@ -508,6 +509,16 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R
}
}
}
+
+ def checkOverrideDeprecated() {
+ if (other.hasDeprecatedOverridingAnnotation) {
+ val msg =
+ member.toString + member.locationString + " overrides " + other.toString + other.locationString +
+ ", but overriding this member is deprecated" +
+ other.deprecatedOverridingMessage.map(": " + _).getOrElse(".")
+ unit.deprecationWarning(member.pos, msg)
+ }
+ }
}
val opc = new overridingPairs.Cursor(clazz)