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. --- test/files/pos/t8954.flags | 1 + test/files/pos/t8954/t1.scala | 13 +++++++++++++ test/files/pos/t8954/t2.scala | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 test/files/pos/t8954.flags create mode 100644 test/files/pos/t8954/t1.scala create mode 100644 test/files/pos/t8954/t2.scala (limited to 'test/files') diff --git a/test/files/pos/t8954.flags b/test/files/pos/t8954.flags new file mode 100644 index 0000000000..7de3c0f3ee --- /dev/null +++ b/test/files/pos/t8954.flags @@ -0,0 +1 @@ +-Xfatal-warnings -deprecation diff --git a/test/files/pos/t8954/t1.scala b/test/files/pos/t8954/t1.scala new file mode 100644 index 0000000000..3986d9f3b5 --- /dev/null +++ b/test/files/pos/t8954/t1.scala @@ -0,0 +1,13 @@ +package scala.foo + +// 1. a class about to be made final +@deprecatedInheritance class A { + def foo(): Unit = ??? +} + +// 1.1: +// - no inheritance warning because same file +// - no "override non-deprecated member" because @deprecatedInheritance +class B2 extends A { + @deprecated("","") override def foo(): Unit = ??? +} diff --git a/test/files/pos/t8954/t2.scala b/test/files/pos/t8954/t2.scala new file mode 100644 index 0000000000..4def127832 --- /dev/null +++ b/test/files/pos/t8954/t2.scala @@ -0,0 +1,39 @@ +package scala.foo + +// 1.2 deprecated children should be fine... +@deprecated("", "") class B extends A { + + // 1.3 and shouldn't trigger the + // "overriding non-deprecated parent" warning + override def foo(): Unit = ??? +} + +@deprecated("","") class F { + // 1.4 a class inside a deprecated class should work too + class G extends A +} + +// 2. a method about to be made final +class C { + @deprecatedOverriding def foo(): Unit = ??? +} + +// 2.1 overriding with a deprecated def should be fine +// and also shoudln't trigger the "deprecation is useless" +// warning +class D extends C { + @deprecated("","") override def foo(): Unit = ??? +} + +// 2.2 overriding from a deprecated class should be fine +@deprecated("","") class E extends C { + override def foo(): Unit = ??? +} + +// 2.3 overriding from deeper inside a deprecated class +// should work too +@deprecated("","") class H { + class I extends C { + override def foo(): Unit = ??? + } +} -- cgit v1.2.3