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

STC: checker confused by overridden method from sub interface

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.2
    • 2.0.4
    • Static Type Checker
    • None

    Description

      interface MyCloseable {
          void close()
      }
      
      interface OtherCloseable extends MyCloseable {
          void close()
      }
      
      class MyCloseableChannel implements OtherCloseable {}
      
      @groovy.transform.TypeChecked
      class Test {
          static void test() {
              def mc = new MyCloseableChannel()
              mc.close()
          }   
      }
      
      Test.test()
      

      Here, OtherCloseable redefines close() from MyCloseable, and it seems to confuse the type checker, as it complains with:

      [Static type checking] - Cannot find matching method MyCloseableChannel#close(). Please check if the declared type is right and if the method exists.
      

      I found the case with java.nio.Channel which redefines the close() method from parent interface java.io.Closeable.

      Attachments

        Activity

          People

            melix Cédric Champeau
            guillaume Guillaume Sauthier
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: