Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.7.6
-
Fix Version/s: 2.0.8, 2.1.3, 2.2.0-beta-1
-
Component/s: Compiler
-
Labels:None
-
Environment:Mac OS X 10.6.6
IntelliJ 10.0.1
-
Testcase included:yes
-
Number of attachments :
Description
In Java you can define abstract methods for an enum type to override it with a concrete method in a constant-specific class body (see Effective Java, 2nd Ed., page 152). When I try to do the same in Groovy I get a compilation error:
Can't have an abstract method in a non-abstract class. The class 'Day' must be declared abstract or the method 'java.lang.String getAction()' must be implemented.
This compilation error can be reproduced with this enum:
enum Day { SUNDAY { String getAction() { 'Relax' } }, MONDAY { String getAction() { 'Work' } } abstract String getAction() }
An enum in Groovy should provide the same behavior for enums as Java.