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

@TypeChecked and @CompileStatic is not aware of interfaces hierarchy

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0-rc-2
    • 2.0-rc-3
    • None
    • None

    Description

      @TypeChecked and @CompileStatic doesn't compile code which use interface hierarchy. It only checks methods defined in used interface, not inherited from ancestors.

      Example:

      import groovy.transform.TypeChecked
      
      class ClassUnderTest {
      
          @TypeChecked
          void methodFromString(SecondInterface si) {
              si.methodFromSecondInterface();
              si.methodFromFirstInterface();
          }
      }
      
      interface FirstInterface {
          void methodFromFirstInterface();
      }
      
      interface SecondInterface extends FirstInterface {
          void methodFromSecondInterface();
      }
      

      Compiler throws an error:

      [Static type checking] - Cannot find matching method SecondInterface#methodFromFirstInterface()

      For class hierarchy it works and code below compiles:

      import groovy.transform.TypeChecked
      
      class ClassUnderTest {
      
          @TypeChecked
          void methodFromString(SecondInterface si) {
              si.methodFromSecondInterface();
              si.methodFromFirstInterface();
          }
      }
      
      class FirstInterface {
          void methodFromFirstInterface() { };
      }
      
      class SecondInterface extends FirstInterface {
          void methodFromSecondInterface() { };
      }
      

      Attachments

        Activity

          People

            melix Cédric Champeau
            filus Filip Pająk
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: