| Summary: | Java 8 map functionality does not work when using ternary operator in return clause | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Michael Strasser <mistrasser1> |
| Component: | Core | Assignee: | Sasikanth Bharadwaj <sasikanth.bharadwaj> |
| Status: | VERIFIED DUPLICATE | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | jarthana, manoj.palat, sasikanth.bharadwaj |
| Version: | 4.5 | ||
| Target Milestone: | 4.6 M1 | ||
| Hardware: | PC | ||
| OS: | Windows 7 | ||
| Whiteboard: | |||
Not reproducible on master. Fixed via changes for bug 463728 *** This bug has been marked as a duplicate of bug 463728 *** Verified for 4.6 M1 with build I20150803-2000. |
Hi, when I am using the new map-functionality of Java 8 and I return a string, it works like a charme if I directly return a String like here: new TreeSet<String>().stream(). map(l -> { String prefix = (true) ? "a" : "b"; return prefix; }). collect(Collectors.joining(",")); However, if I do not use the variable and directly return the result of the ternary operator, like below, I get a compilation error in eclipse: new TreeSet<String>().stream(). map(l -> { return (true) ? "a" : "b"; }). collect(Collectors.joining(",")); The compilation error states: The method collect(Collector<? super Object,A,R>) in the type Stream<Object> is not applicable for the arguments (Collector<CharSequence,capture#10-of ?,String>) Both variants work with the normal Java compiler outside of Eclipse.