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

Static type checking error at Iterable<T> loop

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.3.7, 2.4.0-beta-3
    • 2.3.8, 2.4.0-beta-4
    • Static Type Checker
    • None

    Description

      I can compile this if I change Iterable to Collection.

      import groovy.transform.CompileStatic
      
      @CompileStatic
      class Test {
          static void test(Iterable<Integer> list) {
              for (Integer obj : list) {}
          }
      }
      
      Test.test([0])
      
      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      Test.groovy: 6: [Static type checking] - Cannot loop with element of type java.lang.Integer with collection of type java.lang.Iterable <Integer>
       @ line 6, column 9.
                 for (Integer obj : list) {}
                 ^
      
      1 error
      

      Attachments

        Activity

          People

            blackdrag Jochen Theodorou
            yukoba Yu Kobayashi
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: