scala / bug

Scala 2 bug reports only. Please, no questions — proper bug reports only.
https://scala-lang.org
230 stars 21 forks source link

Scalac should notice Java Deprecated on Scala program elements #12845

Closed som-snytt closed 6 months ago

som-snytt commented 10 months ago

Reproduction steps

Scala version: 2.13.11

scala> @Deprecated def f = 42
def f: Int

scala> f
val res0: Int = 42

Problem

scalac does nothing with @Deprecated on Scala elements.

It should either warn that it is a typo for @deprecated or just use it.

Noticed at https://github.com/scala/bug/issues/12714#issuecomment-1677824530

unkarjedy commented 10 months ago

I would vote for "just use it". Who knows how much Scala code uses @Deprecated intentionally for whatever reasons (e.g. some Scala library is supposed to be used from Java code)

kapunga commented 10 months ago

I also think that "just use it" is reasonable. I've accidentally used the wrong @Deprecated before and not noticed. Could I give this a go? I just forked scala/scala and was looking for an issue to contribute on to learn the process. I think I see the code changes that need to happen for this and have a branch on my fork just using it:

scala> @Deprecated def f = 42
def f: Int

scala> f
       ^
       warning: method f is deprecated
val res0: Int = 42