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

Static compilation fails with multiple bounds generics

    XMLWordPrintableJSON

Details

    Description

      Consider the following interfaces:

      public interface H1 {
        String getFoo();
      }
      
      public interface H2 {
        String getBar();
      }
      

      and the following Groovy class:

      @CompileStatic
      class HGroovy {
      	public <T extends H1 & H2> void doSomething(T obj) {
      		obj.foo
      		obj.bar
      	}
      }
      

      Compilation fails:

      HGroovy.groovy: 9: [Static type checking] - No such property: bar for class: T
       @ line 9, column 3.
                      obj.bar
      

      Attachments

        Activity

          People

            emilles Eric Milles
            mauromol Mauro Molinari
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: