Anonymous classes with diamond, subexpression excludes bounds of type variable

Georgiy Rakov georgiy.rakov at
Tue Jun 2 17:37:32 UTC 2015


new assertion for the new "anonymous classes with diamond" feature 
specified in JDK-8073593 
comment states:

    The term "subexpression" includes type arguments of parameterized
    types (4.5), bounds of wildcards (4.5.1), and element types of array
    types (10.1). /_*It excludes bounds of type variables*_/.***

The part of assertion I'm interested in is emphasized above. Could you 
please tell if you consider this part of assertion as testable and if 
you do could you please provide the example of the code verifying this 
The example I can think out is presented below:

    class Foo<T, U extends T> {...}

that is type variable U is bounded by type variable T which can be 
inferred as a capture variable, inaccessible type or intersection type. 
But if this happens instance creation of anonymous Foo class will still 
result in compiler error because Foo will get parameterized by the 
inferred type T (T is a Foo type variable besides the fact that it's a 
bound of U).

Thank you,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the compiler-dev mailing list