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

Require named arguments for java defined annotations #21329

Merged
merged 2 commits into from
Aug 6, 2024

Conversation

hamzaremmal
Copy link
Member

Closes #20554

@hamzaremmal hamzaremmal requested a review from sjrd August 5, 2024 13:29
@Gedochao Gedochao added the needs-minor-release This PR cannot be merged until the next minor release label Aug 5, 2024
compiler/src/dotty/tools/dotc/typer/Checking.scala Outdated Show resolved Hide resolved
compiler/src/dotty/tools/dotc/typer/Namer.scala Outdated Show resolved Hide resolved
@sjrd sjrd removed their assignment Aug 6, 2024
annot match
case untpd.Apply(fun, params) if hasOnePositionalParameter(params) && annotationHasValueField =>
untpd.cpy.Apply(annot)(fun, params.mapConserve(mapPositionalToNamed))
case untpd.Apply(_, params) =>
Copy link
Member Author

Choose a reason for hiding this comment

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

@sjrd I removed the following condition here: hasOnePositionalParameter(params)

@hamzaremmal hamzaremmal requested a review from sjrd August 6, 2024 12:56
@hamzaremmal hamzaremmal enabled auto-merge August 6, 2024 12:56
@hamzaremmal hamzaremmal added the release-notes Should be mentioned in the release notes label Aug 6, 2024
@hamzaremmal hamzaremmal merged commit e90cf0d into scala:main Aug 6, 2024
27 checks passed
@hamzaremmal hamzaremmal deleted the i20554 branch August 6, 2024 15:31
hamzaremmal added a commit that referenced this pull request Aug 20, 2024
…1397)

Followup to #21329
It might be beneficial for Scala 3.6 migration to allow for an automatic
rewrite of unnamed Java annotation parameters to ease the migration.
We can assume that already compiling code is already using correct
positions for annotation arguments.
Based on that, we can use the order of the annotation decls and their
indexes to assume the names of annotation arguments
@WojciechMazur WojciechMazur added this to the 3.6.0 milestone Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-minor-release This PR cannot be merged until the next minor release release-notes Should be mentioned in the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Compiler should enforce named arguments for Java annotations
4 participants