35

I'd like Scala compiler to show a deprecation warning whenever a particular function is found used. How can I achieve this?

Ivan
  • 63,011
  • 101
  • 250
  • 382

2 Answers2

38

Annotate it as @deprecated.

Daniel C. Sobral
  • 295,120
  • 86
  • 501
  • 681
36

I didn't notice the comment, kristian-domagala, so here is the example:

@deprecated("Reason this is old","01-08-2014")
def oldMethod = {          
  ...      
}
Ciaran
  • 243
  • 1
  • 3
  • 10
flapjack
  • 704
  • 1
  • 8
  • 13
  • 2
    Now it's: @deprecated("don't use this", "01/01/2014") – gwenzek Jul 22 '14 at 21:58
  • 3
    The `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