Change in type inference behaviour with JDK-8078024

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Tue Jul 7 23:58:13 UTC 2015


My understanding is that 8078024 should have been mostly a cleanup with 
performance-related issues (i.e. less time to converge to a non-existent 
solution). But Vicente did the work and might know few things more about 
this one, so let's hear from him.

Maurizio

On 07/07/15 22:34, Liam Miller-Cushon wrote:
> The fix for JDK-8078024 resolved an issue with type inference I was 
> seeing with javac9. I can't tell from the bug report if that was 
> deliberate.
>
> Could someone please confirm that the current behaviour is correct?
>
> Here's the repro. It fails with jdk9-dev @2888, and compiles cleanly 
> @2889:
>
> === A.java ===
> import java.util.Arrays;
> import java.util.List;
>
> class A {
>   public static <B> List<List<B>> cartesianProduct(List<? extends 
> B>... lists) {
>     return cartesianProduct(Arrays.asList(lists));
>   }
>
>   public static <B> List<List<B>> cartesianProduct(List<? extends 
> List<? extends B>> lists) {
>     throw new AssertionError();
>   }
> }
> ===
>
> $ javac A.java
> A.java:6: error: incompatible types: inference variable B has 
> incompatible bounds
>     return cartesianProduct(Arrays.asList(lists));
>                            ^
>     equality constraints: B
>     lower bounds: T,List<? extends B>
>   where B,T are type-variables:
>     B extends Object declared in method <B>cartesianProduct(List<? 
> extends B>...)
>     T extends Object declared in method <T>asList(T...)
> Note: /usr/local/google/home/cushon/A.java uses unchecked or unsafe 
> operations.
> Note: Recompile with -Xlint:unchecked for details.
> 1 error



More information about the compiler-dev mailing list