I am trying to return an object, which should be an implementation of IClass with a generic type, which is an implementation of IType.
public IClass<IType> createClass()
{
return new ActualClass();
}
The actual class I want to return extends the class (abstract), with the generic type ActualType:
public class ActualClass extends Class<ActualType>
An abstract class object implements the IClass interface and can be of any type that extends IType
public abstract class Class<T extends IType> implements IClass<T>
ActualType just implements the IType interface
public final class ActualType implements IType
I get the message "Type mismatch error: cannot convert from ActualClass to IClass" when compiling. I cannot understand why, since ActualClass implements IClass (indirectly through a class), and ActualType implements IType.
How can I change this so that it works? What have I done wrong or misunderstood?
IClass IType, , ActualClass, , IType.