File tree Expand file tree Collapse file tree 5 files changed +57
-3
lines changed
src/compiler/scala/tools/nsc/typechecker Expand file tree Collapse file tree 5 files changed +57
-3
lines changed Original file line number Diff line number Diff line change @@ -543,7 +543,7 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans
543543 }
544544
545545 def checkOverrideDeprecated () {
546- if (other.hasDeprecatedOverridingAnnotation) {
546+ if (other.hasDeprecatedOverridingAnnotation && ! member.ownerChain.exists(x => x.isDeprecated || x.hasBridgeAnnotation) ) {
547547 val suffix = other.deprecatedOverridingMessage map (" : " + _) getOrElse " "
548548 val msg = s " overriding ${other.fullLocationString} is deprecated $suffix"
549549 currentRun.reporting.deprecationWarning(member.pos, other, msg)
@@ -1404,7 +1404,7 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans
14041404 if (symbol.isDeprecated) {
14051405 val concrOvers =
14061406 symbol.allOverriddenSymbols.filter(sym =>
1407- ! sym.isDeprecated && ! sym.isDeferred)
1407+ ! sym.isDeprecated && ! sym.isDeferred && ! sym.hasDeprecatedOverridingAnnotation && ! sym.enclClass.hasDeprecatedInheritanceAnnotation )
14081408 if (! concrOvers.isEmpty)
14091409 currentRun.reporting.deprecationWarning(
14101410 tree.pos,
Original file line number Diff line number Diff line change @@ -1657,7 +1657,8 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
16571657
16581658 val sameSourceFile = context.unit.source.file == psym.sourceFile
16591659
1660- if (! isPastTyper && psym.hasDeprecatedInheritanceAnnotation && ! sameSourceFile) {
1660+ if (! isPastTyper && psym.hasDeprecatedInheritanceAnnotation &&
1661+ ! sameSourceFile && ! context.owner.ownerChain.exists(x => x.isDeprecated || x.hasBridgeAnnotation)) {
16611662 val suffix = psym.deprecatedInheritanceMessage map (" : " + _) getOrElse " "
16621663 val msg = s " inheritance from ${psym.fullLocationString} is deprecated $suffix"
16631664 context.deprecationWarning(parent.pos, psym, msg)
Original file line number Diff line number Diff line change 1+ -Xfatal-warnings -deprecation
Original file line number Diff line number Diff line change 1+ package scala .foo
2+
3+ // 1. a class about to be made final
4+ @ deprecatedInheritance class A {
5+ def foo (): Unit = ???
6+ }
7+
8+ // 1.1:
9+ // - no inheritance warning because same file
10+ // - no "override non-deprecated member" because @deprecatedInheritance
11+ class B2 extends A {
12+ @ deprecated(" " ," " ) override def foo (): Unit = ???
13+ }
Original file line number Diff line number Diff line change 1+ package scala .foo
2+
3+ // 1.2 deprecated children should be fine...
4+ @ deprecated(" " , " " ) class B extends A {
5+
6+ // 1.3 and shouldn't trigger the
7+ // "overriding non-deprecated parent" warning
8+ override def foo (): Unit = ???
9+ }
10+
11+ @ deprecated(" " ," " ) class F {
12+ // 1.4 a class inside a deprecated class should work too
13+ class G extends A
14+ }
15+
16+ // 2. a method about to be made final
17+ class C {
18+ @ deprecatedOverriding def foo (): Unit = ???
19+ }
20+
21+ // 2.1 overriding with a deprecated def should be fine
22+ // and also shoudln't trigger the "deprecation is useless"
23+ // warning
24+ class D extends C {
25+ @ deprecated(" " ," " ) override def foo (): Unit = ???
26+ }
27+
28+ // 2.2 overriding from a deprecated class should be fine
29+ @ deprecated(" " ," " ) class E extends C {
30+ override def foo (): Unit = ???
31+ }
32+
33+ // 2.3 overriding from deeper inside a deprecated class
34+ // should work too
35+ @ deprecated(" " ," " ) class H {
36+ class I extends C {
37+ override def foo (): Unit = ???
38+ }
39+ }
You can’t perform that action at this time.
0 commit comments