The first part of the condition requires that either S <: T or S :> T , that is, one class must inherit from another; otherwise there will be a compile-time error. So, your basic setup is as follows:
class T { } class S extends T { }
So far, so good: you are allowed to drop S into T because there is a corresponding subclass relation between the two classes.
Now let's look at the second part of the condition: two classes must have different supertypes. Since only one superclass is allowed, the common supertype must be an interface. Here is one example of how to break the second part of a rule:
// X is List<String> class T implements List<String> { } // Y is List<Integer> class S extends T implements List<Integer> { }
Erasing both X and Y must implement List<???> , but the list must be parameterized with a different type. This causes a compile-time error because S unable to satisfy the List<String> and List<Integer> interfaces.
dasblinkenlight
source share