下面有什么问题Class A
不允许它编译?
public class GenericsHell {
interface Shape{}
interface Circle extends Shape {}
interface ShapeHelper<T extends Shape> {
void draw(T shape);
}
class A<T extends Shape> {
A(T shape, ShapeHelper<? extends Shape> helper) {
helper.draw(shape); // Issues not-applicable argument error
}
}
class B {
B(Circle circle, ShapeHelper<Circle> helper) {
helper.draw(circle);
}
}
}
Eclipse 给出以下错误:
The method draw(capture#1-of ? extends Shape) in the type ShapeHelper<capture#1-of ? extends Shape> is not applicable for the arguments (T)