I have the following code snippet which returns a type mismatch error:
@SuppressWarnings("rawtypes")
public Map<String, Class<? extends SomeClass.SuperClass>> subClass() {
return Collections.singletonMap("hello", SomeClass.SubClass.class);
}
The class declaration looks like the following:
public class SomeClass {
public static abstract class SuperClass { }
public static class SubClass extends SuperClass{ }
}
This returns a type mismatch error, stating:
Type mismatch: cannot convert from Map<String,Class<SubClass>> to Map<String,Class<? extends SuperClass>>
Why is this occurring? Regardless of whether I use "? extends SuperClass" or just "SuperClass" in the parameterized return type of subClass(), I still see this same error. I've also tried just extending SomeClass instead but that hasn't worked either.