Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 472307 - filter(Objects::nonNull) changes Stream type to <Object> fails cast
Summary: filter(Objects::nonNull) changes Stream type to <Object> fails cast
Status: VERIFIED DUPLICATE of bug 463728
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.5   Edit
Hardware: PC Mac OS X
: P3 normal (vote)
Target Milestone: 4.6 M1   Edit
Assignee: Stephan Herrmann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-07-09 13:55 EDT by Jared Stehler CLA
Modified: 2015-08-04 06:15 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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