| Summary: | Unexpected "Type mismatch: cannot convert" message that javac (including 1.9.0-ea-b70) does not produce | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Geir Helleloid <geir.helleloid> |
| Component: | Core | Assignee: | Stephan Herrmann <stephan.herrmann> |
| Status: | CLOSED DUPLICATE | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | stephan.herrmann |
| Version: | 4.5 | ||
| Target Milestone: | 4.5.1 | ||
| Hardware: | PC | ||
| OS: | Mac OS X | ||
| Whiteboard: | To be verified for 4.6 M6 | ||
I can reproduce using 4.5.0. This bug has been fixed via Bug 469753 (4.6M1 & 4.5.1). The fix has later been improved via Bug 487746 (4.6 M6). *** This bug has been marked as a duplicate of bug 469753 *** |
This code: public class TestClass { public static final <T> java.util.stream.Collector<T, ?, java.util.Optional<T>> findOnly() { return java.util.stream.Collectors.collectingAndThen( java.util.stream.Collectors.toList(), list -> list.size() == 1 ? java.util.Optional.of(list.get(0)) : java.util.Optional.empty() ); } } compiles with javac 1.8.40, javac 1.9.0-ea-b70, and Eclipse 4.4, but it fails to compile in Eclipse 4.5.0 build 20150621-1200 with the error message Type mismatch: cannot convert from Collector<Object,capture#18-of ?,Object> to Collector<T,?,Optional<T>> I thought this was an instance of bug 469653 until I found that javac 1.9.0-ea-b70 compiled it successfuly (unlike in bug 469653).