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

Inferred type is Object when having a complex inheritance chain of interfaces

    XMLWordPrintableJSON

Details

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

    Description

      This seems related to GROOVY-11012.

      I have the following program

      @Grab('org.apache.commons:commons-collections4:4.4')
      import org.apache.commons.collections4.iterators.*;
      
      class Main {
        @groovy.transform.TypeChecked test() {
          EmptyListIterator<Number> tmp = null
          Number x = tmp.next()
        }
      }
      

      Actual behavior

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      test.groovy: 6: [Static type checking] - Cannot assign value of type java.lang.Object to variable of type java.lang.Number
       @ line 6, column 16.
             Number x = tmp.next();
                        ^
      
      1 error
      

      Expected behavior

      Compile successfully

      Notes

      Tested against master (commit: ed4b33c8d5ac71ee4963d6bb391850593c59e5b1)

      https://commons.apache.org/proper/commons-collections/javadocs/api-4.4/org/apache/commons/collections4/iterators/EmptyListIterator.html

      Attachments

        Issue Links

          Activity

            People

              emilles Eric Milles
              theosot Thodoris Sotiropoulos
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: