Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-2933

List Parameter in Enum constructor with misbehavior

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.5.6
    • 1.6-rc-1, 1.5.8, 1.7-beta-1
    • None
    • None

    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"

      Attachments

        1. 2933Patch.zip
          2 kB
          Roshan Dawrani

        Activity

          People

            blackdrag Jochen Theodorou
            mos M.Oliver Scheele
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: