Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.4.1
-
None
-
None
Description
The attached statictraitmethods.zip contains the following:
src/main/groovy/demo/SomeTrait.groovy
package demo import groovy.transform.CompileStatic @CompileStatic trait SomeTrait { static someMethod() { List theNames = getNames() theNames } static List getNames() { ['Jeff', 'Betsy', 'Jake', 'Zack'] } }
The code will not compile:
$ ./gradlew clean test :clean UP-TO-DATE :compileJava UP-TO-DATE :compileGroovy startup failed: /Users/jeff/statictraitmethods/src/main/groovy/demo/SomeTrait.groovy: 9: [Static type checking] - Cannot find matching method demo.SomeTrait#getNames(). Please check if the declared type is right and if the method exists. @ line 9, column 25. List theNames = getNames() ^ 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: 5.148 secs
This may be the same problem as that described in GROOVY-7191. That issue describes the problem as relating to calling static methods from an instance method. The example above suggests that the problem is more general than that.
Attachments
Attachments
Issue Links
- is related to
-
GROOVY-7191 CompileStatic Will Not Allow Instance Method In Trait To Call Static Method
- Closed
- relates to
-
GROOVY-8854 MissingMethodException when a public method on a trait calls a static private one in a class hierarchy
- Closed