Skip to content

Commit 8c1c858

Browse files
committed
Follow-up for non-warning nilary/nullary override with BeanProperty
Follow-up for PR 10450 which stopped the nilary / nullary override warning for synthesized BeanProperty getters. The fix only worked by accident. The BeanProperty annotation class is only meta-annotated to target the field, not the generated bean getter. However, `beanGetterSymbol.hasAnnotation(BeanPropertyAttr)` was still true because the annotation is an `ExtraLazyAnnotationInfo`, which overrides `symbol` to always return the initial symbol even after the underlying `LazyAnnotationInfo` is mapped to `UnmappableAnnotation` by annotation filtering (`Namer.annotSig.computeInfo`). This PR changes `ExtraLazyAnnotationInfo.symbol` to call `super.symbol` if the underlying `LazyAnnotationInfo` is forced. To fix the check in RefChecks, `BeanProperty` and `BooleanBeanProperty` are now meta-annotated with `@beanGetter` and `@beanSetter`.
1 parent d2fda97 commit 8c1c858

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

library/src/scala/beans/BeanProperty.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
package scala.beans
1414

15+
import scala.annotation.meta.{beanGetter, beanSetter, field}
16+
1517
/** When attached to a field, this annotation adds a setter and a getter
1618
* method following the Java Bean convention. For example:
1719
* {{{
@@ -26,6 +28,6 @@ package scala.beans
2628
* For fields of type `Boolean`, if you need a getter named `isStatus`,
2729
* use the `scala.beans.BooleanBeanProperty` annotation instead.
2830
*/
29-
@scala.annotation.meta.field
31+
@field @beanGetter @beanSetter
3032
@deprecatedInheritance("Scheduled for being final in the future", "2.13.0")
3133
class BeanProperty extends scala.annotation.StaticAnnotation

library/src/scala/beans/BooleanBeanProperty.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@
1212

1313
package scala.beans
1414

15+
import scala.annotation.meta.{beanGetter, beanSetter, field}
16+
1517
/** This annotation has the same functionality as
1618
* `scala.beans.BeanProperty`, but the generated Bean getter will be
1719
* named `isFieldName` instead of `getFieldName`.
1820
*/
19-
@scala.annotation.meta.field
21+
@field @beanGetter @beanSetter
2022
@deprecatedInheritance("Scheduled for being final in the future", "2.13.0")
2123
class BooleanBeanProperty extends scala.annotation.StaticAnnotation

0 commit comments

Comments
 (0)