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

STC: for-each loop on iterable-like types

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.0.9, 4.0.0
    • 4.0.1
    • None
    • None

    Description

      Follow up from GROOVY-8133. Using a Stream or other iterable-like type (provides iterator() method but does not implement Iterable) in a for-each loop works but does not provide type inference beyond Object for the loop element type.

      Consider the following:

      @groovy.transform.TypeChecked
      void test() {
        for (e in ['a','b','c'].stream()) {
          println e.toUpperCase()
        }
      }
      

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: