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

SC: produce direct method call for assignment of collection to array

    XMLWordPrintableJSON

    Details

      Description

      Consider the following:

      @groovy.transform.CompileStatic
      void test() {
        def list = [1, 2, 3, 4]
        Number[] array = list
        println array
      }
      test()
      

      Groovy supports the implicit conversion "array = list" under STC/SC as of GROOVY-10002 and GROOVY-8983. Can the static compilation mode replace the call to DefaultTypeTransformation#castToType with a direct call to the collection's toArray() or toArray(T[])?

        Attachments

          Activity

            People

            • Assignee:
              emilles Eric Milles
              Reporter:
              emilles Eric Milles
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 40m
                40m