JDK-8063052 : Inference chokes on wildcard derived from method reference
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 8,9
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2014-11-05
  • Updated: 2015-06-04
  • Resolved: 2014-11-20
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
8u40Fixed 9 b42Fixed
Related Reports
Relates :  
This will not compile:

    void test(Box<? extends Box<? extends Number>> b) {
        Number n = b.map(Box::get).get();

    interface Func<S,T> { T apply(S arg); }

    interface Box<T> {
        T get();
        <R> Box<R> map(Func<T,R> f);

error: incompatible types: inferred type does not conform to upper bound(s)
        Number n = b.map(Box::get).get();
    inferred: ? extends Number
    upper bound(s): Object

If I remove the wildcards, there is no error.

Perhaps javac is failing to capture the return type of Box.get?
Also fails without inference, if I provide an explicit type argument: error: incompatible types: bad return type in method reference Number n = b.<Number>map(Box::get).get(); ^ ? extends Number cannot be converted to Number