Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.0.6
-
None
Description
Don't think I've reported this before...
This code works fine:
@groovy.transform.CompileStatic def List<Integer> append( Closure<Integer> method ) { List<Integer> ret = [] ret << method() } Closure<Integer> cl = { 2 } // prints '[2]' println append( cl )
However, if you use a generic placeholder like so:
@groovy.transform.CompileStatic
def <T> List<T> append( Closure<T> method ) {
List<T> ret = []
ret << method()
}
Closure<Integer> cl = { 2 }
println append( cl )
You get:
[Static type checking] - Cannot call org.codehaus.groovy.runtime.DefaultGroovyMethods#leftShift(java.util.Collection <T>, java.lang.Object) with arguments [java.util.List <T>, java.lang.Object]
Shouldn't that be ok?