I have a Generic method that should work similarly to recursion, but calling different instances of the method for each calling.

```
public <M extends A> void doSomething(Class<M> mClass, M mObject)
{
    // ... Do something with mObject.

    A object = getObject();
    Class<? extends A> objectClass = object.getClass();

    doSomething(objectClass, objectClass.cast(object)); // Does not compile.
}

private A getObject() {...}

```

The problem is the line with a comment does not compile, giving the following error:

> 
> The method doSomething(Class, M) in the type MainTest is not applicable for the arguments (Class, capture#3-of ? extends A)
> 
> 
> 

I don't quite understand why the compiler does not compile if it can call `doSomething` with M = "? extends A".

Why doesn't it compile?