[ https://issues.apache.org/jira/browse/GROOVY-11683?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Eric Milles resolved GROOVY-11683. ---------------------------------- Fix Version/s: 4.0.28 Resolution: Fixed https://github.com/apache/groovy/commit/7b6fd8dfef75161b9ded8aa17f6f62b31817c6be https://github.com/apache/groovy/commit/e60fbb082a8572dfcec2dffd96ae9966be198297 > 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 > Fix For: 4.0.28 > > > 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)