class deprecated(message: String, since: String) extends ConstantAnnotation

An annotation that designates that a definition is deprecated. A deprecation warning is issued upon usage of the annotated definition.

Library authors should state the library's deprecation policy in their documentation to give developers guidance on how long a deprecated definition will be preserved.

Library authors should prepend the name of their library to the version number to help developers distinguish deprecations coming from different libraries:

@deprecated("this method will be removed", "FooLib 12.0")
def oldMethod(x: Int) = ...

The compiler will emit deprecation warnings grouped by library and version:

aDeprecatedMethodFromLibraryBar(3, 4)

// warning: there was one deprecation warning (since BarLib 3.2)
// warning: there were two deprecation warnings (since FooLib 12.0)
// warning: there were three deprecation warnings in total; re-run with -deprecation for details

@deprecated in the Scala language and its standard library

A deprecated element of the Scala language or a definition in the Scala standard library will be preserved at least for the current major version.

This means that an element deprecated in some 2.13.x release will be preserved in all 2.13.x releases, but may be removed in the future. (A deprecated element might be kept longer to ease migration, but developers should not rely on this.)

Value parameters


the message to print during compilation if the definition is accessed


a string identifying the first version in which the definition was deprecated


See also
class Annotation
class Object
trait Matchable
class Any
Show all
In this article