-
Type:
Bug
-
Status: Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 2.2.1
-
Fix Version/s: 2.2.2
-
Component/s: Static compilation
-
Labels:None
Given the following:
import groovy.transform.CompileStatic import java.util.concurrent.Callable interface CustomCallable<T> { T call() } class Thing { static <T> T customType(CustomCallable<T> callable) { callable.call() } static <T> T callable(Callable<T> callable) { callable.call() } @CompileStatic static void run() { callable { [] }.add(1) // return type is inferred - passes compile customType { [] }.add(1) // return type is not inferred - fails compile } }
The problem is visible in the run() method above.
It would be extremely useful for typed DSLs if the return type can be inferred for SAM coercion.