Skip to content

Improve handling of Java annotations, avoid cycles #6978

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 3 commits into from
Aug 2, 2019

Conversation

smarter
Copy link
Member

@smarter smarter commented Jul 31, 2019

No description provided.

smarter added 3 commits July 30, 2019 21:43
It turns out that Java annotations cannot have type parameters, so part
of this method was dead code.
Previously, we made up default getters that were then recognized by the
backend, this has at least two downsides:
- Creating the default getters requires forcing the info of all the
methods in the annotation class, this might lead to cycles.
- This scheme leaks into Tasty, and therefore becomes part of the Tasty
specification, this is inelegant at best.

In the new scheme, no default getters are created, instead we
special-case the typing of annotation constructors: when an argument for
the annotation constructor is missing, we replace it with a typed
wildcard Ident if the corresponding parameter is known to have a default
value. The Tasty spec and the backend need to be aware of this usage of
wildcard, but that's easier to specify and to implement than default
getters.
Compute the info of synthesized Java annotation constructors lazily,
just like the info of all the other members created by ClassfileParser.

Thanks to noti0na1 for the initial investigation and test case!
@odersky odersky merged commit b3fac38 into scala:master Aug 2, 2019
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