| Summary: | [1.8][inference] passing conditionally selected method to map | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Włodzimierz Rękawek <wrekawek> |
| Component: | Core | Assignee: | Stephan Herrmann <stephan.herrmann> |
| Status: | CLOSED MOVED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | manoj.palat, stephan.herrmann |
| Version: | 4.10 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows 10 | ||
| URL: | https://github.com/eclipse-jdt/eclipse.jdt.core/pull/296 | ||
| Whiteboard: | |||
|
Description
Włodzimierz Rękawek
This is accepted by ecj:
Optional.ofNullable(BigDecimal.ZERO)
.<BigDecimal>map((1 == 2) ? BigDecimal::negate : java.util.function.Function.identity())
.orElse(BigDecimal.ZERO);
Ergo: a valid inference solution exists, which is accepted when explicitly specified.
But ecj rejects even this despite the target type:
Optional<BigDecimal> r = Optional.ofNullable(BigDecimal.ZERO)
.map((1 == 2) ? BigDecimal::negate : java.util.function.Function.identity());
At least this can be inferred:
Function<? super BigDecimal,? extends BigDecimal> f = b ? BigDecimal::negate : java.util.function.Function.<BigDecimal>identity();
ecj versions prior to 4.5M4 actually accepted all this.
Will need to observe inference in the debugger to see where it fails.
Will try to look into this in the 4.11 time frame, time permitting.
Bulk move out of 4.11 Bulk move out of 4.13 This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie. I was lucky to identify what looks like the root cause here: we did not correctly implement the last bullet from JLS 15.12.2.1: * A class instance creation expression, a method invocation expression, or an expression of a standalone form (§15.2) is potentially compatible with any type. Over to https://github.com/eclipse-jdt/eclipse.jdt.core/pull/296 |