我有一个下面的方法,它返回一个包含所有元素的枚举集Types
:
@Override
public EnumSet<?> groupTypes() {
return EnumSet.allOf(Types.class);
}
如下所示Types
:enum
public enum Types implements GroupType {
ASG;
}
GroupType
界面是:
public interface GroupType extends NamedType {
}
NamedType
界面:
public interface NamedType {
String name();
}
编译时,出现以下错误:
error: incompatible types: inference variable E has incompatible bounds
return EnumSet.allOf(Types.class);
^
equality constraints: Types
upper bounds: Enum<CAP#1>,Enum<E>
where E is a type-variable:
E extends Enum<E> declared in method <E>allOf(Class<E>)
where CAP#1 is a fresh type-variable:
CAP#1 extends Enum<CAP#1> from capture of ?