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

withIndex().collect loses type parameters

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Duplicate
    • 4.0.13
    • None
    • Static Type Checker
    • None

    Description

      With static compilation, the types of the parameters to withIndex().collect{} are lost.

      This example fails to compile:

      import groovy.transform.CompileStatic
      
      @CompileStatic  // compiles without this
      class WithIndexCollectParameters {
      
          List<String> myList = []
      
          void myMethod() {
             myList.withIndex().collect { String str, int idx ->  // [Static type checking] - Expected type java.lang.Object for closure parameters
                true
             }
          }
      }
      

      Attachments

        Issue Links

          Activity

            People

              emilles Eric Milles
              jasongarrett Jason Garrett
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: