Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
3.0.11, 2.5.18, 4.0.4
-
None
Description
Given:
- A Java class having a method returning a generic Collection,
- A groovy script compiled with "CompileStatic" and using the method of the JavaClass
Then the type of the element of the collection is not correctly inferred.
Example:
public class Bridge { // java public <T extends File> Collection<T> getFiles() { return null; } }
and the following script:
@groovy.transform.CompileStatic
def cst() {
new Bridge().files.collect { it.name }
}
the compilation fails with the error:
[Static type checking] - No such property: name for class: java.lang.Object
Note:
- It works in v3.0.10 but not in v3.0.11
- It works if the class is defined in the groovy script
- A repro is available here: https://github.com/j3rem1e/groovy-bug-generic (>mvn test)
Attachments
Issue Links
- is related to
-
GROOVY-10153 STC: cannot combine use-variance with bounded polymorphism
- Closed
-
GROOVY-10651 STC: closure parameter type inference for raw type that is iterable over type parameter
- Closed
-
GROOVY-10671 STC fails to compile AssertJ fluent API expression
- Closed
- relates to
-
GROOVY-11258 AssertJ collection mapping is badly supported
- Resolved
-
GROOVY-11163 Class parsing does not set erasure of type param with bounds
- Closed