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

annotations and [package|regular] objects #3115

Open
scabug opened this issue Feb 27, 2010 · 8 comments
Open

annotations and [package|regular] objects #3115

scabug opened this issue Feb 27, 2010 · 8 comments

Comments

@scabug
Copy link

scabug commented Feb 27, 2010

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:

[scalacfork] /scala/trunk/src/library/scala/util/parsing/syntax/package.scala:14: error: expected start of definition
[scalacfork] package object syntax {
[scalacfork] ^
[scalacfork] one error found

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:

scala> scala.Math   
<console>:5: warning: object Math in package scala is deprecated: use scala.math package instead

scala> scala.Math.Pi
res0: Double = 3.141592653589793

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.)

@scabug
Copy link
Author

scabug commented Feb 27, 2010

Imported From: https://issues.scala-lang.org/browse/SI-3115?orig=1
Reporter: @paulp

@scabug
Copy link
Author

scabug commented Mar 8, 2010

@odersky said:
(In r21100) Closes #3115. Reviw by rytz

@scabug
Copy link
Author

scabug commented Mar 21, 2012

@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.

@scabug
Copy link
Author

scabug commented Mar 21, 2012

@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.

@scabug
Copy link
Author

scabug commented Feb 14, 2017

@janekdb said:
Confirming that package level deprecation remains unimplemented.

Context: scala/scala-parser-combinators#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] ^

@SethTisue
Copy link
Member

#12496 notes that @nowarn is also affected

@scala scala deleted a comment from scabug Nov 16, 2021
@scala scala deleted a comment from scabug Nov 16, 2021
@SethTisue
Copy link
Member

SethTisue commented Nov 16, 2021

This seems like a good project for an interested contributor.

Is it fixed in Scala 3?

@som-snytt
Copy link

//@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.

@SethTisue SethTisue added this to the 2.13.10 milestone Jun 30, 2022
@SethTisue SethTisue modified the milestones: 2.13.10, 2.13.11 Sep 29, 2022
@SethTisue SethTisue modified the milestones: 2.13.11, 2.13.12 Mar 28, 2023
@SethTisue SethTisue modified the milestones: 2.13.12, Backlog Aug 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants