Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I mark a function as deprecated in Scala?

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

like image 387
Ivan Avatar asked Feb 20 '12 01:02

Ivan


People also ask

How do you make a method deprecated?

Using the @Deprecated Annotation To use it, you simply precede the class, method, or member declaration with "@Deprecated." Using the @Deprecated annotation to deprecate a class, method, or field ensures that all compilers will issue warnings when code uses that program element.

Can I use a deprecated function?

You can still use deprecated code without performance being changed, but the whole point of deprecating a method/class is to let users know there's now a better way of using it, and that in a future release the deprecated code is likely to be removed.

Is Scala deprecated?

The Scala team has decided to enact a special deprecation policy for Scala 2.12: As an upgrade from 2.11 to 2.12 also requires upgrading from Java 6 to Java 8, deprecated elements will not normally be removed in this release, to ease migration and cross-building.

What happens when a method is deprecated?

Similarly, when a class or method is deprecated, it means that the class or method is no longer considered important. It is so unimportant, in fact, that it should no longer be used at all, as it might well cease to exist in the future. The need for deprecation comes about because as a class evolves, its API changes.


1 Answers

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

@deprecated("Reason this is old","01-08-2014") def oldMethod = {             ...       } 
like image 88
flapjack Avatar answered Sep 18 '22 14:09

flapjack