rewrite-static-analysis icon indicating copy to clipboard operation
rewrite-static-analysis copied to clipboard

Unnecessary explicit type arguments removes necessary type arguments

Open pstreef opened this issue 1 year ago • 1 comments

In the following sample the type arugment <String> is remove. But this is required by the .map(this::mapper)

public class Test {
    void test(){
        Stream.of("hi")
                .map(it -> it == null ? Optional.<String>empty() : Optional.of(it))
                .flatMap(Optional::stream)
                .map(this::mapper);
    }

    Optional<String> mapper(String value){
        return Optional.ofNullable(value)
                .filter("hi"::equals);
    }
}
image

pstreef avatar Aug 25 '23 06:08 pstreef