groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eric Milles (JIRA)" <>
Subject [jira] [Created] (GROOVY-8116) Property generation for enum is incorrect
Date Sat, 11 Mar 2017 18:37:04 GMT
Eric Milles created GROOVY-8116:

             Summary: Property generation for enum is incorrect
                 Key: GROOVY-8116
             Project: Groovy
          Issue Type: Bug
            Reporter: Eric Milles

When creating a simple enum, I noticed that content assist was giving some strange results.
 It appears as though there is no special case handling for properties in an enum.
enum Suit {
  int color
  Suit(int color) {
    this.color = color

Since this is an enum, the final modifier on color should not be necessary -- it is implied.
 Java does not require it.  However the generated field does not indicate final in the AST
and a setter setColor is created.  I checked this in the Groovy Console.
final public class Suit implements groovy.lang.GroovyObject extends java.lang.Enum<Suit>

    final public static Suit HEARTS 
    final public static Suit DIAMONDS 
    final public static Suit SPADES 
    final public static Suit CLUBS 
    private int color
    public int getColor() {
    public void setColor(int value) {

The method setColor is coming up in my IDE's content assist, since it is generated by the
Verifier.visitProperty method.  I think if the generated fields are indicated as final for
enums then Verifier will not generate setters.

This message was sent by Atlassian JIRA

View raw message