I noticed that if a case class is deprecated its companion object is not.
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)
I would like to get a warning for A(0)
exactly as I get it for new A(0)
. Should I define the companion object explicitly and deprecate it ? Is there any better way ?
Should I define the companion object explicitly and deprecate it ?
Apparently so! According to https://issues.scala-lang.org/browse/SI-2799 , it should be deprecated automatically (and it makes sense to me), but it doesn't seem to be anymore.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.