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

Groovy 4 can not compile super.foo with generic interface (or trait) method

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 4.0.0
    • 4.0.2, 3.0.20
    • None
    • None

    Description

      package com.company.test
      
      import groovy.transform.CompileStatic
      
      @CompileStatic
      interface IService<T> {
          default void save(T entity) {
              System.out.println(entity);
          }
      }
      
      @CompileStatic
      interface IServiceString {
          default void save(String entity) {
              System.out.println(entity);
          }
      }
      
      @CompileStatic
      class TestGenericGroovy implements IService<String> {
          void save(String entity) {
              // IService<String>.super.save(entity) // works
              super.save(entity) // doesn't work: Groovyc: [Static type checking] - Abstract method save(T) cannot be called directly
          }
          static void main(String[] args) {
              new TestGenericGroovy().save("test")
          }
      }
       

      Attachments

        1. image-2022-02-17-10-53-45-797.png
          93 kB
          Xiaoguang Wang
        2. image-2022-02-17-10-56-36-832.png
          247 kB
          Xiaoguang Wang

        Issue Links

          Activity

            People

              emilles Eric Milles
              wxiaoguang Xiaoguang Wang
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: