-
Enhancement
-
Resolution: Fixed
-
P3
-
5.0
-
b28
-
generic
-
solaris_8
With generic class Class, there is a compatibility problem
in code such as
Class c = b ? A.class : B.class;
This would be illegal (neither Class<A> nor Class<B>
is a subtype of the other). We propose to resolve this using the same
algorithm we use for type inference of a call to a method whose signature is
<T> T f(boolean b, T t1, T t2);
Using the wildcard notation, the type of the right-hand-side of the
assignment above is Class<?>, which is compatible with raw Class, so
the assignment as a whole succeeds.
in code such as
Class c = b ? A.class : B.class;
This would be illegal (neither Class<A> nor Class<B>
is a subtype of the other). We propose to resolve this using the same
algorithm we use for type inference of a call to a method whose signature is
<T> T f(boolean b, T t1, T t2);
Using the wildcard notation, the type of the right-hand-side of the
assignment above is Class<?>, which is compatible with raw Class, so
the assignment as a whole succeeds.