JDK-8185655 : type inference regression after JDK-8175235
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 9
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2017-08-01
  • Updated: 2017-12-07
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.
Other
tbd_minorUnresolved
Related Reports
Relates :  
Description
The following program is accepted by 9-ea+160 and rejected by 9-ea+161. Was this a deliberate change? The likely culprit appears to be JDK-8175235.

===
import java.util.List;
import java.util.function.Function;

abstract class T {

  Iterable<Integer> test(Iterable<String> xs, Function<String, List<? extends Number>> f) {
    return (Iterable) g(h(i(xs, f)));
  }

  abstract <T> Iterable<T> g(Iterable<T> xs);
  abstract <T> Iterable<T> h(Iterable<? extends Iterable<? extends T>> xs);
  abstract <F, T> Iterable<T> i(Iterable<F> xs, Function<? super F, ? extends T> f);
}
===

$ javac -fullversion T.java
javac full version "9-ea+160"
Note: T.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

$ javac -fullversion T.java
javac full version "9-ea+161"
T.java:7: error: incompatible types: inference variable T has incompatible bounds
    return (Iterable) g(h(i(xs, f)));
                       ^
    upper bounds: Iterable<? extends CAP#1>,Object
    lower bounds: List<? extends Number>
  where T,F are type-variables:
    T extends Object declared in method <F,T>i(Iterable<F>,Function<? super F,? extends T>)
    F extends Object declared in method <F,T>i(Iterable<F>,Function<? super F,? extends T>)
  where CAP#1 is a fresh type-variable:
    CAP#1 extends Number from capture of ? extends Number
Comments
Another example: === import java.util.List; import java.util.function.Function; abstract class T { interface C<V> {} interface I {} interface O {} abstract <I, O> C<O> f(C<I> f, final Function<? super I, ? extends O> function); abstract <T> C<List<T>> g(Iterable<? extends C<? extends T>> f); abstract <F, T> Iterable<T> h(Iterable<F> var0, Function<? super F, ? extends T> var1); C<O> f(List<I> ix) { return f( g( h( ix, new Function<I, C<?>>() { public C<?> apply(I i) { return null; } })), new Function<List<?>, O>() { public O apply(List<?> i) { return null; } }); } } === T.java:15: error: incompatible types: inference variable T has incompatible bounds return f( ^ upper bounds: C<? extends CAP#1>,Object lower bounds: C<?> where T,F are type-variables: T extends Object declared in method <F,T>h(Iterable<F>,Function<? super F,? extends T>) F extends Object declared in method <F,T>h(Iterable<F>,Function<? super F,? extends T>) where CAP#1 is a fresh type-variable: CAP#1 extends Object from capture of ?
04-08-2017