Skip to content
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

Respect java.lang.Deprecated annotation even in Scala sources #10517

Merged
merged 2 commits into from Dec 20, 2023

Conversation

kapunga
Copy link
Contributor

@kapunga kapunga commented Aug 28, 2023

Fixes scala/bug#12845
Removes the restriction of java.lang.Deprecated to just Java source.

@scala-jenkins scala-jenkins added this to the 2.13.13 milestone Aug 28, 2023
@SethTisue SethTisue added the release-notes worth highlighting in next release notes label Aug 28, 2023
@SethTisue
Copy link
Member

(Thanks! Note that we're currently winding up 2.13.12, so it might be a few weeks before we consider this for 2.13.13.)

@He-Pin
Copy link
Contributor

He-Pin commented Aug 28, 2023

I missed this very much, thanks.

@SethTisue
Copy link
Member

It may be confusing to users that both annotations exist and are supported. May I suggest adding something to the Scaladoc for the Scala annotation that explains why one might wish to use it instead of the Java one...?

@lrytz
Copy link
Member

lrytz commented Nov 29, 2023

@kapunga are you interested in coming back to this (see Seth's comment above)?

Also, could you extend the existing lint for deprecations to suggest using scala.deprecated when encountering Java's Deprecated? See here:

https://github.com/scala/scala/blob/v2.13.12/src/compiler/scala/tools/nsc/typechecker/Typers.scala#L4206-L4207

Currently (with this PR):

➜ sandbox qs -Xlint
Welcome to Scala 2.13.12-20230828-034507-4cb2928 (OpenJDK 64-Bit Server VM, Java 17.0.6).
Type in expressions for evaluation. Or try :help.

scala> @deprecated def f = 1
        ^
       warning: Specify both message and version: @deprecated("message", since = "1.0")
def f: Int

scala> @Deprecated def g = 1
def g: Int

scala> g
       ^
       warning: method g is deprecated
val res0: Int = 1

Fixes scala/bug#12845
Removes the restriction of java.lang.Deprecated to just Java source.

Also fixes several unit tests. If we are acception @java.lang.Deprecated
on Scala files, several partests (t9529, t9644, t9644b) have deprecation
warnings in the output. We expect these.
@lrytz lrytz force-pushed the 12845-use-java-deprecation branch 3 times, most recently from 259de48 to edc977b Compare December 19, 2023 10:18
@lrytz
Copy link
Member

lrytz commented Dec 19, 2023

Pushed my changes. Review by @som-snytt?

Copy link
Contributor

@som-snytt som-snytt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very accommodating. It's possible the commit title at-mentions Herr Edeling.

@som-snytt som-snytt changed the title Always use java.lang.Deprecated annotation Always respect java.lang.Deprecated annotation Dec 20, 2023
@lrytz lrytz merged commit 97c2515 into scala:2.13.x Dec 20, 2023
4 checks passed
@som-snytt
Copy link
Contributor

To clarify, Daniel Edeling's handle is "deprecated".

@SethTisue SethTisue changed the title Always respect java.lang.Deprecated annotation Respect java.lang.Deprecated annotation even in Scala sources Feb 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-notes worth highlighting in next release notes
Projects
None yet
6 participants