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

Wrong error reported by @CompileStatic when overriding a method returning a parameterized value

    XMLWordPrintableJSON

Details

    Description

      Consider the following Java class:

      package l;
      
      public class LJava <T extends Number> {
         public T doSomething() {
      	   return null;
         }
      }
      

      and the following Groovy class:

      package l
      import groovy.transform.CompileStatic;
      
      @CompileStatic
      class L extends LJava<Integer> {
      	Integer doSomething() {
      		super.doSomething()
      	}
      }
      

      Static compilation fails because Groovy thinks that doSomething() for LJava<Integer> returns Number instead of Integer.

      Attachments

        Activity

          People

            daniel_sun Daniel Sun
            mauromol Mauro Molinari
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: