Nested generics don't compile in 1.7.0_15, but do in 1.6.0_27.
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Tue Mar 12 08:34:53 PDT 2013
On 12/03/13 15:07, Zhong Yu wrote:
> Class<? extends SubFoo> c1 = SubFoo.class;
This shoud compile, in fact the type of SubFoo.class is Class<? extends
SubFoo>.
> Class<? extends FooString> c2 = c1;
This should also compile:
Class<? extends SubFoo> <: Class<? extends FooString>
SubFoo <: FooString
which is true as FooString is a supertype of the raw SubFoo.
> Class<? extends Foo<String>> c3 = c2;
This should also compile:
Class<? extends FooString> <: Class<? extends Foo<String>>
FooString <: Foo<String>
which is true (by class definition)
> but then this fails
>
> c3 = c1;
This is is correctly rejected:
Class<? extends SubFoo> <: Class<? extends Foo<String>>
SubFoo <: Foo<String>
Note that since we are not using unchekced subtyping recursively, the
above is not true. SubFoo has a raw supetype of Foo, not Foo<String>
Maurizio
More information about the compiler-dev
mailing list