我注意到如果一个案例类被弃用,它的伴生对象不是。
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)
我想得到一个A(0)
与我得到的完全一样的警告new A(0)
。我应该明确定义伴随对象并弃用它吗?有没有更好的办法?