File tree Expand file tree Collapse file tree 2 files changed +14
-5
lines changed
main/java/org/codehaus/groovy/ast
test/groovy/org/codehaus/groovy/ast Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -47,13 +47,9 @@ public class AnnotationNode extends ASTNode {
4747 public static final int RECORD_COMPONENT_TARGET = 1 << 10 ;
4848 public static final int TYPE_TARGET = ANNOTATION_TARGET | 1 ; // GROOVY-7151
4949
50- private static final int ALL_TARGETS = TYPE_TARGET | CONSTRUCTOR_TARGET | METHOD_TARGET
51- | FIELD_TARGET | PARAMETER_TARGET | LOCAL_VARIABLE_TARGET | ANNOTATION_TARGET
52- | PACKAGE_TARGET | TYPE_PARAMETER_TARGET | TYPE_USE_TARGET | RECORD_COMPONENT_TARGET ;
53-
5450 private final ClassNode classNode ;
5551 private Map <String , Expression > members ;
56- private int allowedTargets = ALL_TARGETS ;
52+ private int allowedTargets = 0x4FF ; // GROOVY-11838: JLS 9.6.4.1
5753 private boolean runtimeRetention = false , sourceRetention = false , /*explicit*/ classRetention = false ;
5854
5955 public AnnotationNode (final ClassNode type ) {
Original file line number Diff line number Diff line change @@ -25,6 +25,19 @@ import static org.junit.jupiter.api.Assertions.*
2525
2626final class AnnotationNodeTest {
2727
28+ // GROOVY-11838
29+ @Test
30+ void testIsTargetAllowed () {
31+ def node = new AnnotationNode (ClassHelper . OVERRIDE_TYPE )
32+
33+ assertTrue (node. isTargetAllowed(AnnotationNode . TYPE_TARGET ))
34+ assertTrue (node. isTargetAllowed(AnnotationNode . FIELD_TARGET ))
35+ assertTrue (node. isTargetAllowed(AnnotationNode . METHOD_TARGET ))
36+
37+ assertFalse (node. isTargetAllowed(AnnotationNode . TYPE_USE_TARGET ))
38+ assertFalse (node. isTargetAllowed(AnnotationNode . TYPE_PARAMETER_TARGET ))
39+ }
40+
2841 @Test
2942 void testGetText () {
3043 def node = new AnnotationNode (ClassHelper . OVERRIDE_TYPE )
You can’t perform that action at this time.
0 commit comments