summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2012-09-10 23:25:40 +0200
committerJason Zaugg <jzaugg@gmail.com>2012-09-11 00:19:05 +0200
commit028de5d78225d3eb4d41d87bdbe56b7631ef76d1 (patch)
treea6d847d01d41347c2af488d3b4f5564415a2ab2e /src
parentc78fe024711925c40f9fc15221ea04a6f99a5691 (diff)
downloadscala-028de5d78225d3eb4d41d87bdbe56b7631ef76d1.tar.gz
scala-028de5d78225d3eb4d41d87bdbe56b7631ef76d1.tar.bz2
scala-028de5d78225d3eb4d41d87bdbe56b7631ef76d1.zip
Rescues @deprecated{Inheritance, Overriding}
While they ought to be generalized to aribirary modifier changes before being offered in the standard library, the opportunity to use them in 2.10 is too important to pass up. So for now, they're private[scala]. En route: - made the error messages more concise - fix positioning of inheritance error - improve test coverage
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/RefChecks.scala6
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala9
-rw-r--r--src/library/scala/deprecatedInheritance.scala4
-rw-r--r--src/library/scala/deprecatedOverriding.scala4
4 files changed, 11 insertions, 12 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
index 919250c562..b9ff04c9df 100644
--- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
@@ -512,10 +512,8 @@ 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(".")
+ val suffix = other.deprecatedOverridingMessage map (": " + _) getOrElse ""
+ val msg = s"overriding ${other.fullLocationString} is deprecated$suffix"
unit.deprecationWarning(member.pos, msg)
}
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index df97e451d1..3913c4f815 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -1578,12 +1578,9 @@ trait Typers extends Modes with Adaptations with Tags {
pending += ParentFinalInheritanceError(parent, psym)
if (psym.hasDeprecatedInheritanceAnnotation) {
- val sym = selfType.typeSymbol
- val msg =
- sym.toString + sym.locationString + " inherits from " + psym.toString + psym.locationString +
- ", but inheriting from that class is deprecated" +
- psym.deprecatedInheritanceMessage.map(": " + _).getOrElse(".")
- unit.deprecationWarning(sym.pos, msg)
+ val suffix = psym.deprecatedInheritanceMessage map (": " + _) getOrElse ""
+ val msg = s"inheritance from ${psym.fullLocationString} is deprecated$suffix"
+ unit.deprecationWarning(parent.pos, msg)
}
if (psym.isSealed && !phase.erasedTypes)
diff --git a/src/library/scala/deprecatedInheritance.scala b/src/library/scala/deprecatedInheritance.scala
index c461f6737c..4dd847c7b2 100644
--- a/src/library/scala/deprecatedInheritance.scala
+++ b/src/library/scala/deprecatedInheritance.scala
@@ -16,5 +16,7 @@ package scala
* @param message the message to print during compilation if the class was sub-classed
* @param since a string identifying the first version in which inheritance was deprecated
* @since 2.10
+ * @see [[scala.deprecatedInheritance]]
*/
-class deprecatedInheritance(message: String = "", since: String = "") extends annotation.StaticAnnotation \ No newline at end of file
+private[scala] // for now, this needs to be generalized to communicate other modifier deltas
+class deprecatedInheritance(message: String = "", since: String = "") extends annotation.StaticAnnotation
diff --git a/src/library/scala/deprecatedOverriding.scala b/src/library/scala/deprecatedOverriding.scala
index 9048d5d32d..566cb59431 100644
--- a/src/library/scala/deprecatedOverriding.scala
+++ b/src/library/scala/deprecatedOverriding.scala
@@ -15,5 +15,7 @@ package scala
* @param message the message to print during compilation if the member was overridden
* @param since a string identifying the first version in which overriding was deprecated
* @since 2.10
+ * @see [[scala.deprecatedInheritance]]
*/
-class deprecatedOverriding(message: String = "", since: String = "") extends annotation.StaticAnnotation \ No newline at end of file
+private[scala] // for the same reasons as deprecatedInheritance
+class deprecatedOverriding(message: String = "", since: String = "") extends annotation.StaticAnnotation