Skip to content

@BeanProperty and @BooleanBeanProperty should not replicate field annotations onto generated methods #2252

@scabug

Description

@scabug

If I annotate a field like so:

@foo
@BeanProperty
var bar: String = _

... the generated methods getBar and setBar are given the @foo annotation also. This causes problems for widely used Java libraries that rely on the convention of either the field OR the method being annotated.

Given @BeanProperty's express purpose for Java interoperability, the default behavior for @BeanProperty should be aligned with the prevailing Java convention. The generated getter and setter should not have the underlying field's annotations added.

If a developer wishes to have annotations defined on the Java-visible getter or setter, they should define those methods explicitly in the Scala class, and add the desired annotations manually.

This is not a duplicate of #1846 or #2245. Those tickets both raise this issue, but request that the problem be addressed by either adding more metadata at the Scala language level, or by providing compiler plugins that add knowledge of the annotations in use. For the @BeanProperty use cases, this is overkill. I am requesting that incorrect compiler behavior be removed.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions