Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.0-rc-2
-
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() { }; }