Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
2.0.1
-
None
-
Windows 7
Description
@groovy.transform.CompileStatic class Foo{ def run(){ Closure a ={ int i -> println "First closure "+ i } Closure b ={ String s -> println "Second closure "+ s } a=b a("Testing!") } } Foo f = new Foo() f.run()
With CS applied the code will fail to compile with the following error:
[Static type checking] - Closure argument types: [int] do not match with parameter types: [java.lang.String] at line: 13, column: 11
The compiler is expecting an integer but since the variable 'a' is re-assigned to a new piece of code that takes a String as a parameter this code should work