From 3bd7605d1870cf1f877c32574b6f82bb20132346 Mon Sep 17 00:00:00 2001 From: Antoine Gourlay Date: Tue, 4 Nov 2014 15:29:27 +0100 Subject: SI-8954 Make @deprecated{Overriding,Inheritance} aware of @deprecated. This makes sure that: - there is no warning for a @deprecated class inheriting a @deprecatedInheritance class - there is no warning for a @deprecated method overriding a @deprecatedOverriding method - there is no "deprecation won't work" warning when overriding a member of a @deprecatedInheritance class with a @deprecated member - the above works even if the classes/methods are indirectly deprecated (i.e. enclosed in something @deprecated) This should remove quite a few useless deprecation warnings from the library. --- src/compiler/scala/tools/nsc/typechecker/RefChecks.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (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 af4e9e8927..59d1a6da85 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -543,7 +543,7 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans } def checkOverrideDeprecated() { - if (other.hasDeprecatedOverridingAnnotation) { + if (other.hasDeprecatedOverridingAnnotation && !member.ownerChain.exists(x => x.isDeprecated || x.hasBridgeAnnotation)) { val suffix = other.deprecatedOverridingMessage map (": " + _) getOrElse "" val msg = s"overriding ${other.fullLocationString} is deprecated$suffix" currentRun.reporting.deprecationWarning(member.pos, other, msg) @@ -1404,7 +1404,7 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans if (symbol.isDeprecated) { val concrOvers = symbol.allOverriddenSymbols.filter(sym => - !sym.isDeprecated && !sym.isDeferred) + !sym.isDeprecated && !sym.isDeferred && !sym.hasDeprecatedOverridingAnnotation && !sym.enclClass.hasDeprecatedInheritanceAnnotation) if(!concrOvers.isEmpty) currentRun.reporting.deprecationWarning( tree.pos, -- cgit v1.2.3