diff options
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/RefChecks.scala | 6 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 9 | ||||
-rw-r--r-- | src/library/scala/deprecatedInheritance.scala | 4 | ||||
-rw-r--r-- | src/library/scala/deprecatedOverriding.scala | 4 | ||||
-rw-r--r-- | test/files/neg/t6162-inheritance.check | 10 | ||||
-rw-r--r-- | test/files/neg/t6162-inheritance.scala | 17 | ||||
-rw-r--r-- | test/files/neg/t6162-overriding.check | 7 | ||||
-rw-r--r-- | test/files/neg/t6162-overriding.scala | 11 |
8 files changed, 50 insertions, 18 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 diff --git a/test/files/neg/t6162-inheritance.check b/test/files/neg/t6162-inheritance.check index 69112d7f86..a7d3cc3238 100644 --- a/test/files/neg/t6162-inheritance.check +++ b/test/files/neg/t6162-inheritance.check @@ -1,4 +1,10 @@ -t6162-inheritance.scala:4: error: class SubFoo inherits from class Foo, but inheriting from that class is deprecated: `Foo` will be made final in a future version. +t6162-inheritance.scala:6: error: inheritance from class Foo in package t6126 is deprecated: `Foo` will be made final in a future version. class SubFoo extends Foo + ^ +t6162-inheritance.scala:11: error: inheritance from trait T in package t6126 is deprecated +object SubT extends T + ^ +t6162-inheritance.scala:17: error: inheritance from trait S in package t6126 is deprecated + new S { ^ -one error found
\ No newline at end of file +three errors found diff --git a/test/files/neg/t6162-inheritance.scala b/test/files/neg/t6162-inheritance.scala index 67bd4466c3..7b47b9285a 100644 --- a/test/files/neg/t6162-inheritance.scala +++ b/test/files/neg/t6162-inheritance.scala @@ -1,4 +1,19 @@ +package scala.t6126 + @deprecatedInheritance("`Foo` will be made final in a future version.", "2.10.0") class Foo -class SubFoo extends Foo
\ No newline at end of file +class SubFoo extends Foo + +@deprecatedInheritance() +trait T + +object SubT extends T + +@deprecatedInheritance() +trait S + +object O { + new S { + } +} diff --git a/test/files/neg/t6162-overriding.check b/test/files/neg/t6162-overriding.check index 14221ddc63..e774888d36 100644 --- a/test/files/neg/t6162-overriding.check +++ b/test/files/neg/t6162-overriding.check @@ -1,4 +1,7 @@ -t6162-overriding.scala:7: error: method bar in class SubBar overrides method bar in class Bar, but overriding this member is deprecated: `bar` will be made private in a future version. +t6162-overriding.scala:14: error: overriding method bar in class Bar is deprecated: `bar` will be made private in a future version. override def bar = 43 ^ -one error found +t6162-overriding.scala:15: error: overriding method baz in class Bar is deprecated + override def baz = 43 + ^ +two errors found diff --git a/test/files/neg/t6162-overriding.scala b/test/files/neg/t6162-overriding.scala index 4907dbb075..4cab0c2dee 100644 --- a/test/files/neg/t6162-overriding.scala +++ b/test/files/neg/t6162-overriding.scala @@ -1,8 +1,17 @@ +package scala.t6162 + class Bar { @deprecatedOverriding("`bar` will be made private in a future version.", "2.10.0") def bar = 42 + + @deprecatedOverriding() + def baz = 42 + + def baz(a: Any) = 0 } class SubBar extends Bar { override def bar = 43 -}
\ No newline at end of file + override def baz = 43 + override def baz(a: Any) = 43 // okay +} |