Enum inside enum in Groovy loops forever, why?

Assume the following code:

enum Color {
    RED,
    GREEN,
    BLUE
    enum Type {
        RGBA,
        RGB,
        BGR
    }
    String getHex() {
        //something here
        return "#F00"
    }
    Type getType() {
        //something here
        return Type.RGB
    }
}
println Color.RED.type.name()

I thought that nested ones are enumpossible, but if you try to run this piece of code using groovy (using 2.4.13), it seems like it loops forever and never executes or compiles it.

If I put enum Typeoutside, it works fine.

Why is this happening? Are there any links explaining why this fails?

+4
source share
1 answer

This is a known bug.

https://issues.apache.org/jira/plugins/servlet/mobile#issue/GROOVY-4438

Fixed if you use a new parser parser, which is optional in Groovy 2.6+ and is enabled by default in Groovy 3

+4
source

Source: https://habr.com/ru/post/1693344/


All Articles