Skip to content

Commit 7a15884

Browse files
committed
GROOVY-11900: grab adds static constructor to annotation definition
1 parent 5c297be commit 7a15884

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

src/main/java/groovy/grape/GrabAnnotationTransformation.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@ public void visit(final ASTNode[] nodes, final SourceUnit source) {
205205
Collection<Map<String,Object>> grabExcludeMaps = new ArrayList<>();
206206

207207
for (ClassNode classNode : sourceUnit.getAST().getClasses()) {
208+
if (classNode.isAnnotationDefinition()) continue; // GROOVY-11900
209+
208210
grabAnnotations = new ArrayList<>();
209211
grabExcludeAnnotations = new ArrayList<>();
210212
grabConfigAnnotations = new ArrayList<>();

src/main/java/org/codehaus/groovy/classgen/AnnotationVisitor.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,9 @@ private boolean validateEnumConstant(final Expression exp) {
144144
private boolean checkIfMandatoryAnnotationValuesPassed(final AnnotationNode node) {
145145
boolean ok = true;
146146
for (MethodNode mn : node.getClassNode().getMethods()) {
147-
if (!mn.hasAnnotationDefault() && !node.getMembers().containsKey(mn.getName()) && !"dataVariableNames".equals(mn.getName())) {
148-
// TODO: https://github.com/spockframework/spock/issues/1549 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
147+
// "dataVariableNames" was an incorrectly set up variable in Spock, now removed, but exclusion kept for legacy versions
148+
// https://github.com/spockframework/spock/pull/1596/changes/513bb6e7e19
149+
if (!mn.hasAnnotationDefault() && !mn.isStaticConstructor() && !node.getMembers().containsKey(mn.getName()) && !"dataVariableNames".equals(mn.getName())) {
149150
addError("No explicit/default value found for annotation attribute '" + mn.getName() + "'", node);
150151
ok = false;
151152
}

0 commit comments

Comments
 (0)