Q:

Correct generic types for adding objects to lists in a method

I have a series of shapes (SVGShape) and wish to add them to lists using a single method (which will carry out more logic). The code for adding SVGCircle works but is repetitive.  The code for SVGEllipse represents what I wish to do, so that there is a single method which is agnostic of which type it is passed, but fails to compile. The general type is (I think) List<? extends SVGShape> but this forbids addition of elements (at compile-time). 
Is what I am trying to do possible or does it needs rewriting?
// SVGCircle extends SVGShape
// SVGEllipse extends SVGShape
// List<SVGEllipse> ellipseList;
// List<SVGCircle> circleList;
for (SVGShape shape : shapeList) {
    if (shape instanceof SVGCircle) {
        SVGCircle circle = (SVGCircle) shape; // this compiles and works
        circleList.add(circle);
        circle.setId("circle"+circleList.size());
    } else if (shape instanceof SVGEllipse) {
        SVGEllipse ellipse = (SVGEllipse) shape;
        addToListAndSetId(ellipseList, ellipse); // fails to compile
    }
}
private void addToListAndSetId(List<SVGShape> shapeList, SVGShape shape) {
    shapeList.add(shape);
    // more logic here
    shape.setId(shape.getLocalName().toLowerCase() + shapeList.size());
}

NOTE: 2 answers have now given the correct form of the method. For completeness here is the revised calling syntax:
if (shape instanceof SVGCircle) {
    addToListAndSetId(circleList, (SVGCircle) shape);
} else if (shape instanceof SVGEllipse) {
    addToListAndSetId(ellipseList, (SVGEllipse) shape);
}

A:

If you change the signature of your method to void addToListAndSetId(List<? extends SVGShape>, SVGShape shape), it doesn't allow additions to the List, since nothing is stopping you from passing to the method a List<SVGEllipse> with a SVGRectangle (which you shouldn't be able to add to that List).
You can add a generic type parameter to your method:
private <T extends SVGShape> void addToListAndSetId(List<T> shapeList, T shape) {
    shapeList.add(shape);
    // more logic here
    shape.setId(shape.getLocalName().toLowerCase() + shapeList.size());
}

This way if the first argument is a List<SVGEllipse>, the second argument must be a SVGEllipse, which can be safely added to that list.

