Jea*_*let 17 annotations scala compiler-errors compiler-warnings
我知道两个:
@deprecated("use blabla instead")
用于在客户端代码中使用带注释的定义时,编译器向警告输出添加解释.@implicitNotFound(msg = "more meaningful explanation")
用于在无法找到带注释的定义类型的隐式时输出其他错误消息.看一下CanBuildFrom
,msg可以包含类型的占位符${A}
if if A
是带注释类型的类型参数的名称,由编译器填充实际预期类型,例如:
@implicitNotFound(msg = "Cannot construct a collection of type ${To} with elements of type ${Elem} based on a collection of type ${To}.")
trait CanBuildFrom[-From, -Elem, +To] { ... }
Run Code Online (Sandbox Code Playgroud)还有其他这样的注释吗?
有@migration
一个用于-Xmigration
指示方法从一个版本到另一个版本的语义变化,以帮助版本之间的端口代码.
@migration(2, 8, "As of 2.8, keys returns Iterable[A] rather than Iterator[A].")
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
442 次 |
最近记录: |