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

Compiler loses type info of superclass field

    XMLWordPrintableJSON

    Details

      Description

      foo/bar/classes.java
      package foo.bar;
      
      class F {
          void hi() {}
      }
      
      abstract class Base<T extends F> {
          protected T theField;
      }
      
      abstract class Middle<T extends F> extends Base<T> {}
      
      abstract class Concrete extends Middle<F> {}
      
      foo/bar/GroovyUsage.groovy
      package foo.bar
      
      @groovy.transform.CompileStatic
      class GroovyUsage extends Concrete {
      
          def usage() {
              theField.hi() // Error:(7, 9) Groovyc: [Static type checking] - Cannot find matching method java.lang.Object#hi(). Please check if the declared type is correct and if the method exists.
          }
      }
      

      Note this was working with 2.4.17.

        Attachments

          Activity

            People

            • Assignee:
              daniel_sun Daniel Sun
              Reporter:
              daniilo Daniil Ovchinnikov
            • Votes:
              2 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 1.5h
                1.5h