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

asType for collections should use .addAll if no <init>(Collection) constructor is found

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.8-beta-2
    • 1.8-beta-3
    • None
    • None

    Description

      Today this code produces an error:
      class MyList extends ArrayList {

      public MyList() {}
      }

      def x = [2, 3, 4] as MyList

      This is because MyList does not have a constructor that takes a collection.

      All collections have an addAll(Collection) method.
      If the constructor fails then we should try the default constructor followed by a call to addAll.

      I have the code fixed locally with test and can check in any time. Just want to get approval in case there is a backwards compatibility issue.

      Attachments

        Activity

          People

            hamletdrc Hamlet D'Arcy
            hamletdrc Hamlet D'Arcy
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: