Skip to content

Deprecated case class element warns (twice!) at its definition #17908

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

Closed
som-snytt opened this issue Jun 6, 2023 · 2 comments · Fixed by #17911
Closed

Deprecated case class element warns (twice!) at its definition #17908

som-snytt opened this issue Jun 6, 2023 · 2 comments · Fixed by #17911
Labels
area:reporting Error reporting including formatting, implicit suggestions, etc itype:bug
Milestone

Comments

@som-snytt
Copy link
Contributor

Compiler version

Welcome to Scala 3.3.2-RC1-bin-SNAPSHOT-git-348729e (20.0.1, Java OpenJDK 64-Bit Server VM).

Minimized code

Welcome to Scala 3.3.2-RC1-bin-SNAPSHOT-git-348729e (20.0.1, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.

scala> @deprecated("now","0.1") case class K(k: Int)
// defined case class K

scala> case class K(@deprecated("now","0.1") k: Int)
2 warnings found
-- Deprecation Warning: ------------------------------------------------------------------------------------------------
1 |case class K(@deprecated("now","0.1") k: Int)
  |           ^
  |           value k in class K is deprecated since 0.1: now
-- Deprecation Warning: ------------------------------------------------------------------------------------------------
1 |case class K(@deprecated("now","0.1") k: Int)
  |                                            ^
  |                                            value k in class K is deprecated since 0.1: now
// defined case class K

scala>

Expectation

No deprecation at definition.

Follow-up to #11022.

Noticed at https://github.com/scalapb/ScalaPB/blob/master/scalapb-runtime/src/main/js-native/com/google/protobuf/descriptor/FileOptions.scala#L94

I wonder if this issue is in time for the Scala Days spree!

@som-snytt som-snytt added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Jun 6, 2023
@som-snytt
Copy link
Contributor Author

Contrary to the issue title,

there were 5 deprecation warnings; re-run with -deprecation for details
1 warning found

when re-run with -deprecation

2 warnings found

Whom to believe?

@som-snytt
Copy link
Contributor Author

The answer is 5: in hashCode, twice in equals (this.k == that.k), copy$default$1 and _1.

@dwijnand dwijnand added area:reporting Error reporting including formatting, implicit suggestions, etc stat:needs triage Every issue needs to have an "area" and "itype" label and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Jun 12, 2023
@mbovel mbovel removed the stat:needs triage Every issue needs to have an "area" and "itype" label label Jun 19, 2023
hamzaremmal added a commit that referenced this issue Apr 14, 2024
Synthetic members of case classes should not incur deprecation warnings
when a case element is deprecated.

Fixes #17908

Also when message in Java deprecation is empty, improve
```
-- Deprecation Warning: ------------------------------------------------------------------------------------------------
1 |f
  |^
  |method f is deprecated since :
val res0: Int = 42
```
to
```
-- Deprecation Warning: ------------------------------------------------------------------------------------------------
1 |f
  |^
  |method f is deprecated
val res0: Int = 42
```
@Kordyjan Kordyjan added this to the 3.5.0 milestone May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:reporting Error reporting including formatting, implicit suggestions, etc itype:bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants