Skip to content

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.

@kapunga kapunga force-pushed the 12845-use-java-deprecation branch from 5b03b81 to 4cb2928 Compare August 28, 2023 03:46
@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?

@lrytz lrytz force-pushed the 12845-use-java-deprecation branch from edc977b to 6280a5b Compare December 19, 2023 12:54
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
@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
hamzaremmal pushed a commit to hamzaremmal/scala3 that referenced this pull request May 2, 2025
…ecation

Always respect java.lang.Deprecated annotation
hamzaremmal pushed a commit to scala/scala3 that referenced this pull request May 7, 2025
…ecation

Always respect java.lang.Deprecated annotation
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

Development

Successfully merging this pull request may close these issues.

Scalac should notice Java Deprecated on Scala program elements

6 participants