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

Inherited generic property do not honour type

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.2.1, 2.4.0-beta-3
    • 2.4.0-rc-1
    • Static compilation
    • None
    • Groovy Version: 2.2.1 JVM: 1.7.0_40 Vendor: Oracle Corporation OS: Mac OS X

    Description

      Generic properties do not honour the declared type in the subclass. For example:

      @CompileStatic
      class X<T> {
      
        T target
      
      }
      
      @CompileStatic
      class Y extends X<InputStream> {
      
        def f() {  target.read() }
      
      }

      Reports the following compilation error:

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      test.groovy: 14: [Static type checking] - Cannot find matching method java.lang.Object#read(). Please check if the declared type is right and if the method exists.
      @ line 14, column 14.
      def f() { target.read()

      Attachments

        Activity

          People

            Unassigned Unassigned
            pablo72 paolo di tommaso
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: