change in inference of unchecked calls after JDK-8147493

Liam Miller-Cushon cushon at google.com
Tue Jan 26 04:03:14 UTC 2016


The fix for JDK-8147493 (regression when type-checking unchecked method
calls) prevents the following code from compiling. It is accepted by 8, and
earlier versions of 9-dev. The return type of w(...) is now being inferred
as S<Q<Object>>. Shouldn't the unchecked call cause return types to be
erased?

abstract class Test {

 interface R<E> {}
 interface Q<T> {}
 interface T { <E> Q<E> n(R<E> r); }
 abstract <T> T isA(Class<T> t);
 abstract <T> S<T> w(T t);
 interface S<T> { S<T> t(T value); }

 void f(T t, Q<String> q) {
   w(t.n(isA(R.class))).t(q);
 }
}


error: incompatible types: Q<String> cannot be converted to Q<Object>
   w(t.n(isA(R.class))).t(q);
                          ^

Thanks,
Liam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20160125/ed046bf6/attachment.html>


More information about the compiler-dev mailing list