Mic*_*ael 5 scala deprecated companion-object
我注意到,如果不推荐使用 case 类,则不推荐使用它的伴生对象。
scala> @deprecated case class A(x: Int)
warning: there was one deprecation warning; re-run with -deprecation for details
defined class A
scala> A(0)
res0: A = A(0)
scala> new A(0)
warning: there was one deprecation warning; re-run with -deprecation for details
res1: A = A(0)
Run Code Online (Sandbox Code Playgroud)
我想收到一个警告,A(0)正如我收到的一样new A(0)。我应该明确定义伴随对象并弃用它吗?有没有更好的方法?
我应该显式定义伴随对象并弃用它吗?
显然是这样!根据https://issues.scala-lang.org/browse/SI-2799,它应该被自动弃用(这对我来说很有意义),但它似乎不再是了。
| 归档时间: |
|
| 查看次数: |
230 次 |
| 最近记录: |