[
https://issues.apache.org/jira/browse/GROOVY-10749?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Paul King closed GROOVY-10749.
------------------------------
> STC: closure/lambda/reference parameter as type witness for SAM type generics
> -----------------------------------------------------------------------------
>
> Key: GROOVY-10749
> URL: https://issues.apache.org/jira/browse/GROOVY-10749
> Project: Groovy
> Issue Type: Bug
> Reporter: Eric Milles
> Assignee: Eric Milles
> Priority: Minor
> Fix For: 4.0.5, 2.5.19, 3.0.13
>
>
> Consider the following:
> {code:groovy}
> 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())
> }
> {code}
> 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}}.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)