Reputation: 170859
There is a nice way to avoid deprecation warnings in Scala 2.10 (and before) by invoking the deprecated method from a deprecated local def. Unfortunately, it doesn't work in Scala 2.11. Is there an alternative?
Upvotes: 1
Views: 799
Reputation: 170859
From this Scala issue comment, we can define methods calling deprecated API in a deprecated class/trait, and have the companion object to this class extend it without a warning:
scala> @deprecated("", "") def foo = 0
foo: Int
scala> object Test { @deprecated("", "") class Coral { def fooForwarder = foo }; object Coral extends Coral }
defined object Test
scala> Test.Coral.fooForwarder
res1: Int = 0
Upvotes: 1