Description
Consider the following:
import java.util.function.* import java.util.stream.* import groovy.transform.* class Named { String name } @TypeChecked void test() { def c1 = Collectors.groupingBy(Named::getName) def c2 = Collectors.groupingBy(Named.&getName) def c3 = Collectors.groupingBy{Named named -> named.getName()} def c4 = Collectors.groupingBy((Named named) -> named.getName()) }
In each case, the type inference engine should be able to work out the type of the declared variable as: Collector<Named, ?, Map<String, List<Named>>>
To do so, the parameter type Named (and return type String) must be mapped onto Function<? super T, ? extends K> of Collectors#groupingBy.
Attachments
Issue Links
- is related to
-
GROOVY-10054 STC: Cannot infer lambda parameter types for a stream collector
- Open
- relates to
-
GROOVY-11259 STC loses generic information on method references
- Closed