Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 472307

Summary: filter(Objects::nonNull) changes Stream type to <Object> fails cast
Product: [Eclipse Project] JDT Reporter: Jared Stehler <jared.stehler>
Component: CoreAssignee: Stephan Herrmann <stephan.herrmann>
Status: VERIFIED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: jared.stehler, manoj.palat
Version: 4.5   
Target Milestone: 4.6 M1   
Hardware: PC   
OS: Mac OS X   
Whiteboard:

Description Jared Stehler CLA 2015-07-09 13:55:03 EDT
Only seems to happen when I use braces in the .map lambda:

  public Stream<String> getStream(List<String> list) {
    return list.stream()
        .map(s1 -> {
          return s1.length() > 3 ? s1 : null; 
        })
        .filter(Objects::nonNull);
  }

Description	Resource	Path	Location	Type
Type mismatch: cannot convert from Stream<Object> to Stream<String>	BrokenStreamFilter.java	/sandbox/src/main/java/sandbox	line 19	Java Problem
Comment 1 Timo Kinnunen CLA 2015-07-09 18:24:59 EDT
Bug 469753 is also one where lambda block vs lambda expression makes a difference for inference results.
Comment 2 Stephan Herrmann CLA 2015-07-12 12:19:27 EDT
I can reproduce in 4.5.

This has already been fixed via bug 463728 (4.6 M1).

*** This bug has been marked as a duplicate of bug 463728 ***
Comment 3 Manoj N Palat CLA 2015-08-04 06:15:13 EDT
Verified for Eclipse Neon 4.6 M1 Build id: I20150803-2000