5

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 ?

Michael
  • 41,026
  • 70
  • 193
  • 341

1 Answers1

2

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.

Alexey Romanov
  • 167,066
  • 35
  • 309
  • 487
  • I tried this: `@deprecated("foo","") case class A(x: Int); @deprecated("bar","") object A`, but calling `A(0)` still doesn't give a deprecation warning. – Kolmar Jun 16 '16 at 16:01