[ https://issues.apache.org/jira/browse/GROOVY-8439?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Daniel Sun resolved GROOVY-8439. -------------------------------- Resolution: Fixed Assignee: Daniel Sun Fix Version/s: 2.6.0-alpha-4 2.4.15 2.5.0-rc-1 3.0.0-alpha-2 Fixed by: https://github.com/apache/groovy/commit/7b73c6aeb2d399512b6cdfbb6ff4fbef59c33f9a > @CompileStatic cannot compile generic class's static method > ----------------------------------------------------------- > > Key: GROOVY-8439 > URL: https://issues.apache.org/jira/browse/GROOVY-8439 > Project: Groovy > Issue Type: Bug > Components: Static compilation > Affects Versions: 2.4.12 > Environment: Windows 10, Gradle 4.2.1; > IRL @CompileStatic applied via groovyOptions.configurationScript: > withConfig(configuration) { ast(groovy.transform.CompileStatic) } > Reporter: Robert Papp > Assignee: Daniel Sun > Priority: Blocker > Fix For: 3.0.0-alpha-2, 2.5.0-rc-1, 2.4.15, 2.6.0-alpha-4 > > > Below code is a simplification of a Gradle API + Android Gradle Plugin > consuming code: > {code} > @CompileStatic > class Test<T extends Task> { > static def something(Task task, Collection<BaseVariant> variants) { > variants > .collectMany {it.sourceFolders} > .collect {ConfigurableFileTree tree -> > > task.buildDir.toPath().relativize(tree.dir.toPath()).toString() + > File.separator > } > } > } > interface BaseVariant { > List<ConfigurableFileTree> getSourceFolders() > } > interface ConfigurableFileTree { > File getDir() > } > interface Task { > File getBuildDir() > } > {code} > Removing {{<T extends Task>}} makes it compile, otherwise: > {code} > test\src\main\groovy\Test.groovy: 8: Expected parameter of type Task but got > ConfigurableFileTree > @ line 8, column 15. > .collect {ConfigurableFileTree tree -> > ^ > test\src\main\groovy\Test.groovy: 9: [Static type checking] - No such > property: dir for class: Task > @ line 9, column 38. > > task.buildDir.toPath().relativize(tree.dir.toPath()).toString() + > File.separator > ^ > test\src\main\groovy\Test.groovy: 9: [Static type checking] - Cannot find > matching method java.nio.file.Path#relativize(java.lang.Object). Please check > if the declared type is right and if the method exists. > @ line 9, column 4. > > task.buildDir.toPath().relativize(tree.dir.toPath()).toString() + > File.separator > ^ > 3 errors > :checkstyle:compileGroovy FAILED > {code} > So far I haven't found a workaround other than removing generics! -- This message was sent by Atlassian JIRA (v7.6.3#76005)