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

STC: checker confused by overridden method from sub interface

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.2
    • Fix Version/s: 2.0.4
    • Component/s: Static Type Checker
    • Labels:
      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

            • Assignee:
              melix Cédric Champeau
              Reporter:
              Guillaume Guillaume Delcroix
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: