Skip to content

Fix type inferencing for functional types with complex generics #1626

@eric-milles

Description

@eric-milles

Consider the following:

import java.util.stream.Stream
@groovy.transform.TypeChecked
void test(List<String> list_of_string) {
  def stream_of_list_of_string = Stream.of(list_of_string)
  def stream_of_string = stream_of_list_of_string.flatMap(List::stream)
}

Type inferencing for "flatMap" shows a return type of "Stream" when "Stream" is expected.

Image

The signature for flatMap is as follows -- with the type param R nested in the Function type:

<R> Stream<R> flatMap(Function<? super T, ? extends Stream<? extends R>> mapper)

see also https://issues.apache.org/jira/browse/GROOVY-11683

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions