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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With