JDK-8042656 : Inference produces spurious error for intersection type bounds check
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 9
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2014-05-07
  • Updated: 2014-09-15
  • Resolved: 2014-05-09
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.
JDK 8 JDK 9
8u20Fixed 9 b14Fixed
Related Reports
Relates :  
Description
The following (adapted from Netbeans code in ResultSetJXTable) should compile, but does not after JDK-8033718.  The inferred type is correct -- an intersection CAP#1 & Cloneable -- but the error produced afterwards is wrong.

interface RowFilter<X> {}

<R extends Cloneable> void setRowFilter1(RowFilter<? super R> filter) {
    setRowFilter2(filter); // expected: ok; actual: error
}

<T extends Cloneable> void setRowFilter2(RowFilter<? super T> filter) { }

}

---

error: method setRowFilter2 in class RowFilterError cannot be applied to given types;
    setRowFilter2(filter);
    ^
  required: RowFilter<? super T>
  found: RowFilter<CAP#1>
  reason: inferred type does not conform to upper bound(s)
    inferred: INT#1
    upper bound(s): CAP#1,Cloneable
  where T,R are type-variables:
    T extends Cloneable declared in method <T>setRowFilter2(RowFilter<? super T>)
    R extends Cloneable declared in method <R>setRowFilter1(RowFilter<? super R>)
  where CAP#1 is a fresh type-variable:
    CAP#1 extends Object super: R from capture of ? super R
  where INT#1 is an intersection type:
    INT#1 extends CAP#1,Cloneable