groovy

Cannot create enum type with explicit constructor

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.1-rc-1
  • Fix Version/s: 1.1-rc-2
  • Component/s: None
  • Labels:
    None
  • Environment:
    GroovyConsole, Windows
  • Number of attachments :
    0

Description

According to "Blackdrags View" (http://blackdragsview.blogspot.com/2007_10_01_archive.html) the following enum definition should be possible in Groovy as of rc-1:

enum E {
A(100),B(200),C(300)
def value
E (v) { value = v }
}

When I try this in GroovyConsole, I get a puzzling MultipleCompilationErrorsException:

Exception thrown: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, General error during conversion: org.codehaus.groovy.ast.expr.ConstantExpression cannot be cast to org.codehaus.groovy.ast.expr.ListExpression

I'm not sure if this is really a compilation error or if it's only a misleading message because this kind of enum might not be actually supported.

Activity

Hide
blackdrag blackdrag added a comment -

fixed

Show
blackdrag blackdrag added a comment - fixed

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: