zhong-j-yu/rekex

Annotations should allow ElementType=FIELD for use in singleton enums.

raptor494 opened this issue · 5 comments

When I try to add an @str or @ch annotation to an enum field, I get "Syntax error: Type annotations are illegal here."
This is probably because those annotations are not declared with @target including ElementType.FIELD (for enum fields)
Screen Shot 2021-09-27 at 12 03 15 PM

Sorry about that. Which version of Java are you using?

I was aware of the ambiguity of type annotation on enum field; but it worked (on my machine:)

https://github.com/zhong-j-yu/rekex/blob/main/doc/note-misc.txt

If a enum field is annotated with an anno of @target=Type_USE, it's not clear what happens.
Javac allows it, so it appears that it applies on the type of the field.
But field.getAnnotatedType() does not contain the anno.
And field.getDeclaredAnnotations() does contain the anno.

I think I understand the problem. It is your IDE that reports the error. Since JLS isn't clear on this issue, the IDE cannot be blamed for it. Thanks for reporting.

The issue is fixed in version 1.1.1 - could you try again and see if it works?

Hi @raptor494 , if you have no objections, I'll close this issue as fixed in 24 hours.

Fixed and available since v1.1.1.