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

STC: problem with a getAt call in double nested collect call

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.3.3
    • 2.3.4
    • Static compilation
    • None
    • Mac OS X

    Description

      The following code works well dynamically, properly type checks, but fails static compilation:

      @groovy.transform.CompileStatic test() {
          def versionRanges = [['1.7', 11]]
          versionRanges.collect { versionRange -> versionRange[1].collect { versionRange[0] } }.flatten()
      }
      
      test()
      
      Exception thrown
      
      BUG! exception in phase 'class generation' in source unit 'ConsoleScript23' At line 3 column 45
      On receiver: versionRange with message: getAt and arguments: 1
      This method should not have been called. Please try to create a simple example reproducing this error and filea bug report at http://jira.codehaus.org/browse/GROOVY
      

      Although it's reported on the first versionRange[1], it's actually seems related to the second call (versionRange[0]). If you remove that second call, all is fine.

      Attachments

        Activity

          People

            melix Cédric Champeau
            guillaume Guillaume Sauthier
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: