Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.4.0-beta-4
-
None
Description
The attached compile problem.zip contains the following code:
src/main/groovy/demo/Config.groovy
package demo interface Config {}
src/main/groovy/demo/Holders.groovy
package demo class Holders { static setConfig(Config cfg) {} }
src/main/groovy/demo/Helper.groovy
package demo class Helper { @groovy.transform.CompileStatic void test() { // with 2.4.0-beta-4 this compiles. Config config = new ConfigObject() // with 2.4.0-beta-4 this does not compile. Holders.config = new ConfigObject() // ...with 2.3.7 it all compiles } }
$ ./gradlew cG :compileJava UP-TO-DATE :compileGroovy startup failed: /Users/jeff/t/compileproblem/src/main/groovy/demo/Helper.groovy: 12: [Static type checking] - Cannot assign value of type groovy.util.ConfigObject to variable of type demo.Config @ line 12, column 9. Holders.config = new ConfigObject() ^ 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.552 secs
If I edit build.gradle and change the Groovy version to 2.3.7 it all compiles.
I am not sure why assigning an instance of ConfigObject to a Config reference is allowed. If it is supposed to be allowed because of some proxy generation or something like that, then I am not sure why the property assignment isn't allowed.