Open scabug opened 14 years ago
Imported From: https://issues.scala-lang.org/browse/SI-3115?orig=1 Reporter: @paulp
@odersky said: (In r21100) Closes #3115. Reviw by rytz
@vjovanov said: I am reopening this issue as package objects still can not be deprecated and from the the comments and commits I can not see the clear resolution for that matter.
I would like to deprecate the whole package and I can not do it in any way except by going to all public classes and objects and annotating them with @deprecated. In my case the package has quite a few classes and annotating them is not negligible work.
@paulp said: Yeah, it looks like I did them all manually in scala.Math.
What we need is this:
New meta-annotations in scala.annotation.meta for object and class (of course they can't be called that because the identifiers are reserved) so one can attach an annotation to a package object and designate whether it applies to the package object itself, the whole package, or both. Then the deprecation code has to notice it, which means considering the annotations of all enclosing package objects of any given member when issuing warnings.
@janekdb said: Confirming that package level deprecation remains unimplemented.
Context: https://github.com/scala/scala-parser-combinators/issues/99
Code,
package scala.util.parsing
/**
* This package was never intended for production use; it's really more of a code sample demonstrating how to use parser combinators.
*
* Use [[https://index.scala-lang.org/ The Scala Library Index]] to find alternative JSON parsing libraries.
*/
@deprecated("Use The Scala Library Index to find alternatives: https://index.scala-lang.org/", "1.0.6")
package object json {}
Error,
[error] scala-parser-combinators/shared/src/main/scala/scala/util/parsing/json/package.scala:9: expected start of definition
[error] package object json {}
[error] ^
@nowarn
is also affectedThis seems like a good project for an interested contributor.
Is it fixed in Scala 3?
//@deprecated("do not even", "1.0")
//package object p
package p {
@deprecated("do not even", "1.0")
object `package`
@deprecated("ancient api", "1.0")
class C {
@deprecated("old stuff", "1.0")
def c = 42
def d = c
}
class D {
def f(c: C) = c.c
}
}
This is the working syntax, but it does not suppress the deprecations in D
, and certainly doesn't induce deprecation on D
.
Same result in Scalae 2 & 3.
I was hoping to deprecate a package object ("what? already?") since the whole package has moved and that would be the cleanest way to deprecate the forwarding stubs, but:
As I began this ticket I thought that deprecating an object tagged everything inside it as deprecated, but that doesn't seem to be the case. It is what I had intended for scala.Math, but now I find that referencing it directly gets the warning, but its contents skate by:
Hopefully there is some remedy possible short of directly annotating all several dozen of scala.Math's members. Actually even that isn't much of a remedy because that code is all shared with the undeprecated scala.math package.
(I know nobody would DREAM of suggesting cutting and pasting, so let's not even go there.)