Open lrytz opened 1 month ago
There was a discussion about what should ideally happen on the Scala 2 PR: https://github.com/scala/scala/pull/10792#discussion_r1634404635.
To summarize, given @deprecated case class C(x: Int)
:
C.hashCode
C.apply
to make sure C(1)
warnstype CC = C
, but not when using CC in new CC(1)
.C.apply
also shows up when using an alias (val CC = C; CC.apply(1)
– example v6
in the bug report above). That is an issue, it was just fixed in Scala 2 (#10792).Maybe instead of intercepting the apply
call and warn if the companion class is deprecated, the annotation should be propagated to the synthetic compaion by default.
@deprecated case class C(x: Int)
=> the synthetic companion object C
is deprecatedcase class C @deprecated (x: Int)
=> the synthetic apply
method in the companion object C
is deprecatedDoing that change could affect many projects.
Scala 3.4.2
There are a few spurious deprecations (
warn!
) and a few missing ones (no!
).