summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2013-03-29 19:05:13 +0100
committerJason Zaugg <jzaugg@gmail.com>2013-03-30 10:00:46 +0100
commit54d11fe5451a9f26207ce283f2df1114c89384dd (patch)
tree72a541fb877533066dc736573d3d765ad08551e4 /src
parent7894c1b24fddc91fbec53a9906e3c8b8e8a4e61a (diff)
downloadscala-54d11fe5451a9f26207ce283f2df1114c89384dd.tar.gz
scala-54d11fe5451a9f26207ce283f2df1114c89384dd.tar.bz2
scala-54d11fe5451a9f26207ce283f2df1114c89384dd.zip
SI-7312 @deprecatedInheritance now ignores same-file subclasses
This allows us to deprecate external inheritances as a prelude to sealing a class, without enduring the warnings ourselved in interlude.
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala6
-rw-r--r--src/library/scala/deprecatedInheritance.scala3
2 files changed, 6 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 5e31395215..6719411700 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -1738,14 +1738,16 @@ trait Typers extends Adaptations with Tags {
if (psym.isFinal)
pending += ParentFinalInheritanceError(parent, psym)
- if (psym.hasDeprecatedInheritanceAnnotation) {
+ val sameSourceFile = context.unit.source.file == psym.sourceFile
+
+ if (psym.hasDeprecatedInheritanceAnnotation && !sameSourceFile) {
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)
- if (context.unit.source.file == psym.sourceFile)
+ if (sameSourceFile)
psym addChild context.owner
else
pending += ParentSealedInheritanceError(parent, psym)
diff --git a/src/library/scala/deprecatedInheritance.scala b/src/library/scala/deprecatedInheritance.scala
index 70065560b1..7d20219d4d 100644
--- a/src/library/scala/deprecatedInheritance.scala
+++ b/src/library/scala/deprecatedInheritance.scala
@@ -11,7 +11,8 @@ package scala
/** An annotation that designates that inheriting from a class is deprecated.
*
* This is usually done to warn about a non-final class being made final in a future version.
- * Sub-classing such a class then generates a warning.
+ * Sub-classing such a class then generates a warning. No warnings are generated if the
+ * subclass is in the same compilation unit.
*
* @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