Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.0.5
-
None
Description
If you have a typed Closure as a default parameter of a method ie:
@groovy.transform.TypeChecked Integer a( String s, Closure<Integer> b={ String it -> it.length() } ) { b( s ) } a( 'tim' )
You get the exception:
[Static type checking] - Cannot return value of type java.lang.Object on method returning type java.lang.Integer -> java.lang.Integer
The workaround is to either cast the return:
(Integer)b( s )
Or stop using the default parameter:
@groovy.transform.TypeChecked Integer a( String s ) { Closure<Integer> b={ String it -> it.length() } b( s ) } a( 'tim' )