The method add(capture#2-of ? extends IObject) in the type List is not applicable for the arguments (IDerived)
protected List<? extends IObject> getObjects()
{
List<? extends IObject> objects = new ArrayList<IObject>();
for (String id: item_ids)
{
IDerived object = (IDerived) readObject(id);
objects.add(object); #error
}
return objects;
}
interface IDerived extends interface IVersionedObject extends interface IObject
If I change the type of objects to List then the error goes away, which makes no sense because it has to make exactly the same cast to the function return type.
objectsbe instantiated asnew ArrayList<IDerived>()?