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

ConstantAnnotation's aren't copied fully to module classes symbols #12430

Open
dwijnand opened this issue Jul 14, 2021 · 0 comments
Open

ConstantAnnotation's aren't copied fully to module classes symbols #12430

dwijnand opened this issue Jul 14, 2021 · 0 comments
Milestone

Comments

@dwijnand
Copy link
Member

dwijnand commented Jul 14, 2021

reproduction steps

using Scala 2.13.6, comparing against 2.13.5,

scala> @deprecated("Use other", "v1.2.3") case class C()
class C

scala> :power
Already in power mode.

scala> val sym = typeOf[C].typeSymbol
                        ^
       warning: class C is deprecated (since v1.2.3): Use other
val sym: $r.intp.global.Symbol = class C

scala> val syms = List(sym, sym.companionModule.moduleClass)
val syms: List[$r.intp.global.Symbol] = List(class C, object C)

scala> val annots = syms.map(_.getAnnotation(definitions.DeprecatedAttr).get)
val annots: List[$r.intp.global.AnnotationInfo] = List(deprecated(message = "Use other", since = "v1.2.3"), deprecated)

scala> annots.map(_.args)
val res1: List[List[$r.intp.global.Tree]] = List(List(), List())

scala> annots.map(_.assocs)
val res2: List[List[($r.intp.global.Name, $r.intp.global.ClassfileAnnotArg)]] = List(List((message,"Use other"), (since,"v1.2.3")), List())

problem

The metadata "Use other" is only present on the case class annotation info, it's entirely missing on the module class's annotation info.

In 2.13.5, it's there:

scala> val annots = syms.map(_.getAnnotation(definitions.DeprecatedAttr).get)
val annots: List[$r.intp.global.AnnotationInfo] = List(deprecated("Use other", "v1.2.3"), deprecated("Use other", "v1.2.3"))

scala> annots.map(_.args)
val res0: List[List[$r.intp.global.Tree]] = List(List("Use other", "v1.2.3"), List("Use other", "v1.2.3"))

scala> annots.map(_.assocs)
val res1: List[List[($r.intp.global.Name, $r.intp.global.ClassfileAnnotArg)]] = List(List(), List())

The trigger is likely the change of @deprecated from extends scala.annotation.StaticAnnotation to extends scala.annotation.ConstantAnnotation in scala/scala#9336, but to me it seems to reveal a preexisting bug in how info is copied to the companion symbols and their annotations.

Spawns from lightbend/genjavadoc#286 / lightbend/genjavadoc#287.

@dwijnand dwijnand added this to the Backlog milestone Sep 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant