In the example below, I can't seem to get rid of the unchecked warning (short of suppressing it). As you can see in '2.' specifying the type causes a compile error.
Is suppression the only option here?
static class Cat { }
static class CatGiver<T extends Cat> {
T cat;
CatGiver(T cat) {
this.cat = cat;
}
static <T extends Cat> CatGiver<T> get() {
// 1. Unchecked assignment warning
return new CatGiver(new Cat());
// 2. Compile error on 'new Cat()' "T cannot be applied to Cat..."
// return new CatGiver<T>(new Cat());
}
}