-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
deprecated case class warns at its definition #11022
Comments
This is also an issue for deprecated implicit classes. I assume it's the same basic issue so I'll just add this as a comment rather than opening a new issue. Minimized Codeobject repro {
@deprecated("no ImplicitClass", "0.1") implicit class ImplicitClass(val a: Any)
} Output
ExpectationNo warning, as in Scala 2.13.6 |
would this be a good issue-spree ticket? |
I was going to address it after scala/scala#10071 which ... how did I put it ...
|
Any update about this @som-snytt ,thanks. |
@He-Pin by coincidence, yesterday I deleted the old branch from a year ago, but got distracted by warning on deprecated constant-folded ops. I'll return to this right after that. The interesting lesson from that other fix is that because of structural differences in the pipeline, fixes don't necessarily forward-port directly. |
When adding a companion object with a deprecated annotation, the warning disappears: @deprecated("no CaseClass", "0.1")
case class CaseClass(rgb: Int)
@deprecated("no CaseClass", "0.1")
object CaseClass |
The draft PR is the Scala 2 fix, which specifies suppression by deprecated companion of enclosing element, but the fix is less fussy than Scala 2, at least as a first attempt. Previously excluded was the linked issue #12706 |
As there now is a work-in-progress pull request (#16918) fixing this issue, I remove the “Spree” label so that we don't work on it in parallel. |
I haven't had a chance to return to this issue (both Scala 2 and 3) to evaluate whether my proposal is a bad idea. (That must happen before 2.13.11.) Thanks for the bump. |
This issue was picked for the Issue Spree No. 28 of 28 March 2023 which takes place in a week from now. @SethTisue, @nmcb, @jan-pieter will be working on it. If you have any insight into the issue or guidance on how to fix it, please leave it here. |
Um, I had an idea but maybe don't go down that alley. Thanks, scala-center-bot! Edit: to summarize, Scala 2 only excludes the case ctor call. The rejected idea was that companion of a deprecated class should not see warnings for usages; instead of that implicit exclusion, the companion or its member must explicitly choose Sample changes: |
Indeed! I fixed it in my original comment. |
The Scala 2 PR for this, scala/scala#10071, was merged a while back. @som-snytt thanks for your helpful remarks above, last week. The approach taken in the Scala 2 PR (namely "only exclude the case ctor call") seems satisfactory to me, but I guess we should begin our session by seeing whether we agree on that. |
If we do agree on that, then we don't need to look at #16918, since it takes a different approach, and it doesn't have any test cases that aren't also in scala/scala#10071 . |
(It actually was helpful to look at #16918, not to copy the whole approach, but to steal little bits and pieces of implementation. Thanks @som-snytt.) Here's where things stand: we feel like we're close to having it right, and we just ran out of time. The part we got stuck on is checking whether it's specifically the constructor that we're calling. We want to call Anyway, the next step is that I'll ask @dwijnand to have a look, though it's possible that when I prepare to talk to him I'll spot the problem myself. @nmcb and @jan-pieter, feel free to take your own stab at it in parallel. We shouldn't wait six weeks or we'll forget where we were :-) @jan-pieter will open a draft PR as a reference point. |
@nmcb @jan-pieter wdyt about this as the possible culprit? CrossVersionChecks.scala:141 override def transformNew(tree: New)(using Context): New = {
checkUndesiredProperties(tree.tpe.typeSymbol, tree.srcPos)
tree
}
whereas we were looking for a I think I would have spotted this if we'd had literally 3 more minutes 😅 I'm familiar with |
Both the |
Minimized code
Output
Expectation
no warning as in Scala 2.13.4.
The text was updated successfully, but these errors were encountered: