Skip to content

Don't use a special representation for Java enum values #9930

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

Merged
merged 1 commit into from
Oct 2, 2020

Conversation

smarter
Copy link
Member

@smarter smarter commented Oct 1, 2020

In Java, annotation arguments must be constants, so enum values are
treated specially. In Scala, annotation arguments can be whatever tree
we want, so we don't really need to represent them as
Literal(Constant(enumValueSymbol)) and can just use a TermRef to the
enum value instead.

This commit implements this change, this has several advantages compared
to the status quo:

  • The handling of Java enum values and Scala enum values is now less
    different.
  • We can drop the handling of symbols in Constant
  • ... and therefore remove one tag from Tasty.
  • In turn, this means we don't have to worry about how to expose
    this in tasty-reflect.

This commit breaks the Tasty format and therefore bump its major version
to 24.

@smarter smarter added this to the 3.0.0-M1 milestone Oct 1, 2020
@smarter smarter requested a review from bishabosha October 1, 2020 16:19
In Java, annotation arguments must be constants, so enum values are
treated specially. In Scala, annotation arguments can be whatever tree
we want, so we don't really need to represent them as
`Literal(Constant(enumValueSymbol))` and can just use a `TermRef` to the
enum value instead.

This commit implements this change, this has several advantages compared
to the status quo:
- The handling of Java enum values and Scala enum values is now less
  different.
- We can drop the handling of symbols in `Constant`
- ... and therefore remove one tag from Tasty.
- In turn, this means we don't have to worry about how to expose
  this in tasty-reflect.

This commit breaks the Tasty format and therefore bump its major version
to 24.
@smarter smarter force-pushed the remove-enum-constant branch from 9eb5f10 to ab257d6 Compare October 1, 2020 17:51
Copy link
Member

@bishabosha bishabosha left a comment

Choose a reason for hiding this comment

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

LGTM

@bishabosha bishabosha assigned smarter and unassigned bishabosha Oct 2, 2020
@smarter smarter merged commit 55e378d into scala:master Oct 2, 2020
@smarter smarter deleted the remove-enum-constant branch October 2, 2020 12:11
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.

2 participants