Ian created GROOVY-8538: --------------------------- Summary: <T> static type checking, generics, and collect Key: GROOVY-8538 URL: https://issues.apache.org/jira/browse/GROOVY-8538 Project: Groovy Issue Type: Bug Affects Versions: 2.2.2 Environment: CentOS 7 Gradle 4.6 Reporter: Ian
Broken between 2.2.2 and 2.4.15 (the latest I have access to). {code:java} import groovy.transform.TypeChecked @TypeChecked class MyClass { List<Foo<Bar<Float>>> ii = [] List<Bar<Float>> jj = ii.collect { Foo<Bar<Float>> it -> it.get() } } interface Foo<V> { V get() } abstract class Bar<T> {} {code} Fails to compile with error: {code:java} MyClass.groovy: 6: [Static type checking] - Incompatible generic argument types. Cannot assign java.util.List <Float> to: java.util.List <Bar> @ line 6, column 27. List<Bar<Float>> jj = ii.collect { Foo<Bar<Float>> it -> it.get() } ^ {code} Note that if the type of Foo is changed to <T> it compiles successfully: {code:java} ... interface Foo<T> { T get() } abstract class Bar<T> {} {code} Also successfully compiles if the type of Bar is changed to anything else: {code:java} ... interface Foo<V> { V get() } abstract class Bar<R> {}{code} So it seems there is something special in the use of <T> specifically that makes this fail. This also seems to hold true for classes defined in different files. -- This message was sent by Atlassian JIRA (v7.6.3#76005)