Incompilable instanceof with super-bound

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Thu Mar 16 16:43:27 UTC 2023


I think the original example was passing `new Sub<>()` ? This fails in 
javac, but, from what I understood from Tagir, Eclipse compiles it fine. 
In my analysis (see my last email) I believe I showed this (the 
inference issue, not the cast) to be a bug in the Eclipse compiler (of 
course this area is tricky, so there might be something I missed).

Cheers
Maurizio

On 16/03/2023 15:06, S A wrote:
> public static void main(String[] args) {
> Sub<?> s = new Sub<Box<String>>();
> System.out.println(isSub(new Super<Box<String>>()));
> }
>
> The ecj compile error is:
>
> 1. ERROR in .../test/Test.java (at line 16)
>         System.out.println(isSub(new Super<Box<String>>()));
>                            ^^^^^


More information about the compiler-dev mailing list