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

Compiler should enforce named arguments for Java annotations #20554

Closed
lrytz opened this issue Jun 11, 2024 · 1 comment · Fixed by #21329
Closed

Compiler should enforce named arguments for Java annotations #20554

lrytz opened this issue Jun 11, 2024 · 1 comment · Fixed by #21329
Assignees
Labels
area:annotations compat:java itype:bug needs-minor-release This PR cannot be merged until the next minor release
Milestone

Comments

@lrytz
Copy link
Member

lrytz commented Jun 11, 2024

Java annotation "parameters" are declared as fields

public @interface Ann {
  int a() default 41;
  int b() default 42;
  int c() default 43;
}

Scala 3 allows @Ann(1). Reordering the fields in Ann is a binary compatible change, but it affects the meaning of @Ann(1).

Scala 2 does the same as Java: arguments to Java annotations always have to be specified by name. The only exception is a single positional argument, which always expands to the field named value, i.e., @Ann(value = 1).

@lrytz lrytz added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Jun 11, 2024
@Gedochao Gedochao added compat:java needs-minor-release This PR cannot be merged until the next minor release area:annotations and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Jun 11, 2024
@Gedochao
Copy link
Contributor

Gedochao commented Jul 4, 2024

This has been decided to be worked on in the 3.6.0 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:annotations compat:java itype:bug needs-minor-release This PR cannot be merged until the next minor release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants