groovy
  1. groovy
  2. GROOVY-2933

List Parameter in Enum constructor with misbehavior

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.5.6
    • Fix Version/s: 1.6-rc-1, 1.5.8, 1.7-beta-1
    • Component/s: None
    • Labels:
      None
    • Number of attachments :
      1

      Description

      This one

       
      enum MyEnum {
         ONE ([1,2]),
         TWO  ([3,4]);
         private final List myList
         MyEnum (List myList) {
              this.myList=myList
          }
      }
      MyEnum.ONE
      

      leads to "groovy.lang.GroovyRuntimeException: Could not find matching constructor for: MyEnum(java.lang.String, java.lang.Integer, java.lang.Integer, java.lang.Integer)"

      Adding "as List" to the List declaration works:

       
      enum MyEnum {
         ONE ([1,2] as List),
         TWO  ([3,4] as List);
         private final List myList
         MyEnum (List myList) {
              this.myList=myList
          }
      }
      MyEnum.ONE
      

      Why isn't "[x,y,z]" interpreted as a List in construction of enum instances?
      Bug or a feature?

      -----------
      blackdrag: "looks like a bug for me.. please fill a report in JIRA"

        Activity

          People

          • Assignee:
            blackdrag blackdrag
            Reporter:
            Mos
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: