I'd like Scala compiler to show a deprecation warning whenever a particular function is found used. How can I achieve this?
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.
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.
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.
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.
I didn't notice the comment, kristian-domagala, so here is the example:
@deprecated("Reason this is old","01-08-2014") def oldMethod = { ... }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With