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

more robust annotation retrieval #287

Merged

Conversation

jrudolph
Copy link
Contributor

This started to fail with 2.13.6 as annotation.toString was just deprecated for the companion object. The case class symbol annotation toString itself still seems to contain the parameters.

@SethTisue do you know whether that might have been a change only in toString behavior between 2.13.5 and 2.13.6 or if copying over annotations from case class to it's generated companion object might have changed?

Fixes #286.

This started to fail with 2.13.6 as annotation.toString was just `deprecated`
for the companion object.
@SethTisue
Copy link
Member

SethTisue commented Jul 14, 2021

Looking through the 2.13.6 merged PRs, the only one that jumps out at me is scala/scala#9336 , which changed @deprecated to extend ConstantAnnotation rather than StaticAnnotation

Is there a little experiment we can do in the REPL that demonstrates the changed behavior?

@SethTisue
Copy link
Member

2.13.6:

scala 2.13.6> :power
Already in power mode.

scala 2.13.6> @deprecated("", "") case class C()
class C

scala 2.13.6> typeOf[C].typeSymbol.companionModule.moduleClass.annotations.head.toString
                     ^
              warning: class C is deprecated:
val res0: String = deprecated

whereas in 2.13.5 the result at the end is deprecated("", "")

Copy link
Member

@SethTisue SethTisue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dale and I poked at this for a while and convinced ourselves that scala/scala#9336 is in fact the cause.

In this PR, the new code is better than the old code (depending on toString was inherently fragile), so I think we should go ahead and merge it. (Regardless of whether this should be considered a regression on the Scala side.)

@jrudolph
Copy link
Contributor Author

Dale and I poked at this for a while and convinced ourselves that scala/scala#9336 is in fact the cause.

Thanks! Good to know it's probably something harmless.

@jrudolph jrudolph merged commit ea4e48b into lightbend:main Jul 15, 2021
@jrudolph jrudolph deleted the dont-depend-on-annotation.toString branch July 15, 2021 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

java.util.NoSuchElementException: None.get in BasicTransform.deprecationInfo
3 participants