Description
The attached abstractcompilestatic.zip contains the following:
src/main/groovy/demo/SomeInterface.groovy
package demo interface SomeInterface { void someInterfaceMethod() }
src/main/groovy/demo/AbstractSuperClass.groovy
package demo abstract class AbstractSuperClass implements SomeInterface {}
src/main/groovy/demo/AbstractSubClass.groovy
package demo import groovy.transform.CompileStatic @CompileStatic abstract class AbstractSubClass extends AbstractSuperClass { void someMethod() { someInterfaceMethod() } }
The code will not compile.
$ ./gradlew clean compileGroovy :clean :compileJava UP-TO-DATE :compileGroovy startup failed: /Users/jeff/abstractcompilestatic/src/main/groovy/demo/AbstractSubClass.groovy: 9: [Static type checking] - Cannot find matching method demo.AbstractSubClass#someInterfaceMethod(). Please check if the declared type is right and if the method exists. @ line 9, column 9. someInterfaceMethod() ^ 1 error :compileGroovy FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':compileGroovy'. > Compilation failed; see the compiler error output for details. * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. BUILD FAILED Total time: 4.045 secs
If the AbstractSubClass is modified to implement the interface as shown below the code will compile:
src/main/groovy/demo/AbstractSubClass.groovy
package demo import groovy.transform.CompileStatic @CompileStatic abstract class AbstractSubClass extends AbstractSuperClass implements SomeInterface { void someMethod() { someInterfaceMethod() } }
Attachments
Attachments
Issue Links
- is duplicated by
-
GROOVY-7441 Problem With CompileStatic And Trait Methods In Abstract Subclass
- Closed