[
https://issues.apache.org/jira/browse/GROOVY-11683?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17956670#comment-17956670
]
Christopher Smith commented on GROOVY-11683:
--------------------------------------------
Those inferred types do look correct.
> STC loses generic information on method reference
> -------------------------------------------------
>
> Key: GROOVY-11683
> URL: https://issues.apache.org/jira/browse/GROOVY-11683
> Project: Groovy
> Issue Type: Bug
> Components: Static Type Checker
> Affects Versions: 4.0.27
> Reporter: Christopher Smith
> Assignee: Eric Milles
> Priority: Minor
>
> I am using a typical stream pipeline to get a list of pages of results and
> flatMap them to the individual records:
> {code}
> //
> software.amazon.awssdk.services.cognitoidentityprovider.CognitoIdentityProviderClient
> cognito
> cognito.listUsersPaginator { it.userPoolId(cognitoUserPool) }
> .stream()
> .map(ListUsersResponse::users)
> .flatMap(List::stream) // produces UserType
> .map(UserType::username)
> .toList()
> {code}
> Both groovyc and GRECLIPSE report the compile-time error
> {code}
> Failed to find class method 'username(java.lang.Object)' or instance method
> 'username()' for the type:
> software.amazon.awssdk.services.cognitoidentityprovider.model.UserType
> {code}
> The cause appears to be a failure to propagate the type information out of
> the {{flatMap}} call: On hover, Eclipse correctly identifies the
> {{List::stream}} as returning {{Stream<UserType>}}, but the {{flatMap}} is
> reported as {{Stream<Object>}}. Inserting a type witness before the
> {{flatMap}} call resolves the error. Both the loss of type information and
> the incorrect error message appear to be bugs.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)