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

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

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    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

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

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

                  Issue deployment