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

Cannot static compile for..in when List interface is extended

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.3.0, 2.3.1
    • 2.4.0-beta-4
    • Static compilation
    • None

    Description

      Cannot compile this code in 2.3.0.

      import groovy.transform.CompileStatic
      
      @CompileStatic
      class ForInTest {
          static interface List2<E> extends List<E> {}
          static class ArrayList2<E> extends ArrayList<E> implements List2<E> {}
          static List2 list = new ArrayList2()
      
          static void main(String[] args) {
              for (def e in list) {}
          }
      }
      

      The error message is this.

      Line 10, expecting casting to java.util.Iterator <E extends java.lang.Object> but operand stack is empty

      Maybe this problem is related to GROOVY-6791

      Attachments

        Activity

          People

            Unassigned Unassigned
            yukoba Yu Kobayashi
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: