You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are some edge cases for the targeting of annotations using the meta-annotations where they are not getting applied correctly for classes defined within traits.
The target meta-annotations can be put on the annotation type when instantiating the annotation. In the following example, the annotation @id will be added only to the bean getter getX.
When the meta-annotations are used on classes defined in standalone compilation units or within objects everything behaves correctly. If the annotations are applied to classes defined within traits they get applied to extra methods that shouldn't be. In Scala 2.11.12 and below this only affected a couple of scenarios but in 2.12.0 and newer the behaviour has regressed significantly.
I've created a test harness that applies the different meta-annotations and outputs where the annotations were actually applied. The harness can be found in this gist.
A summary of the results can be seen below:
Test Case
Expected
2.11
2.12
2.13
TestBean.defaultTarget
C
C
C
C
TestBean.fieldTarget
F
F
F
F
TestBean.getterTarget
M
M
M
M
TestBean.beanPropertyDefault
C
C
C
C
TestBean.beanPropertyField
F
F
F
F
TestBean.beanPropertyGetter
M
M
M
M
TestBean.beanPropertyBeanGetter
B
B
B
B
WrappedBean.defaultTarget
C
-
M
M
WrappedBean.fieldTarget
F
F
FMC
FMC
WrappedBean.getterTarget
M
M
M
M
WrappedBean.beanPropertyDefault
C
-
MB
MB
WrappedBean.beanPropertyField
F
FC
FMCB
FMCB
WrappedBean.beanPropertyGetter
M
MC
MC
MC
WrappedBean.beanPropertyBeanGetter
B
B
B
B
Key:
C: constructor
F: field
M: getter method
B: bean getter method
The text was updated successfully, but these errors were encountered:
There are some edge cases for the targeting of annotations using the meta-annotations where they are not getting applied correctly for classes defined within traits.
According to the scaladocs for
scala.annotation.meta
:When the meta-annotations are used on classes defined in standalone compilation units or within objects everything behaves correctly. If the annotations are applied to classes defined within traits they get applied to extra methods that shouldn't be. In Scala 2.11.12 and below this only affected a couple of scenarios but in 2.12.0 and newer the behaviour has regressed significantly.
I've created a test harness that applies the different meta-annotations and outputs where the annotations were actually applied. The harness can be found in this gist.
A summary of the results can be seen below:
TestBean.defaultTarget
TestBean.fieldTarget
TestBean.getterTarget
TestBean.beanPropertyDefault
TestBean.beanPropertyField
TestBean.beanPropertyGetter
TestBean.beanPropertyBeanGetter
WrappedBean.defaultTarget
WrappedBean.fieldTarget
WrappedBean.getterTarget
WrappedBean.beanPropertyDefault
WrappedBean.beanPropertyField
WrappedBean.beanPropertyGetter
WrappedBean.beanPropertyBeanGetter
Key:
The text was updated successfully, but these errors were encountered: