Paul Clapham wrote:
I don't believe the compiler will look through your class hierarchy
Henry Wong wrote:
Can someone with deep knowledge of generics explain this one? First, it is using the diamond operator. This means that the type of the generics (that is being instantiated) is inferred. However, it is also using the wildcard. So, what is the type of the generic? How is it inferred? I have seen code like this before, and this always bothered me....
the 'So the compiler cannot guarantee that '? extends Building' is correct, and therefore it won't compile.
incompatible types: List<CAP#1> cannot be converted to List<? extends Building>
where CAP#1 is a fresh type-variable: CAP#1 extends Object super: Residential from
capture of ? super Residential