I'd like Scala compiler to show a deprecation warning whenever a particular function is found used. How can I achieve this?
Asked
Active
Viewed 1.0k times
2 Answers
38
Annotate it as @deprecated
.

Daniel C. Sobral
- 295,120
- 86
- 501
- 681
-
22And if you don't want deprecation warnings about your deprecation annotations, make sure you supply them with both `message` and `since` arguments. – Kristian Domagala Feb 20 '12 at 03:26
-
1Fixed link: https://www.scala-lang.org/api/2.12.1/scala/deprecated.html – Jeff Evans Oct 28 '19 at 17:29
36
I didn't notice the comment, kristian-domagala, so here is the example:
@deprecated("Reason this is old","01-08-2014")
def oldMethod = {
...
}
-
2
-
3The `since` argument needn't be a date, in fact the docs specify it as "a string identifying the first version in which the definition was deprecated". – Todd Owen Apr 10 '15 at 07:48
-
1@ToddOwen True, I find it useful to put in the commit hash there for example. – Bar Sep 06 '16 at 13:41