I don't understand why the following code generates a warning.
interface Generic<T> {
}
interface A {
}
class B {
Generic<A> c;
<T extends A> B(Generic<T> a) {
c = (Generic<A>) a; //warning here
}
}
//Unchecked cast from Generic<T> to Generic<A>
In class B i'm only interested in using instances of Generic that are of type A. This warning suggests that I need to store the Generic argument as a T instead of A.
But this means I would have to declare B generic also, which seems to make things more complicated than they need to be.