Skip to content

Compiler should enforce named arguments for Java annotations #20554

Closed
@lrytz

Description

@lrytz

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).

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions