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

STC: for-each over Iterator fails to infer element type

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 4.0.4
    • 4.0.5
    • Static Type Checker
    • None

    Description

      Consider the following:

      @groovy.transform.TypeChecked
      void test() {
        def list = ['a','b']
        for (item in list.iterator()) {
          item.toUpperCase() // Cannot find matching method Object#toUpperCase()
        }
      }
      

      Inferred type of "item" is java.lang.Object. Without ".iterator()" it is java.lang.String.

      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: