Because the meaning of MyType depends on its context, our new definition of subtyping will have to consider the different meanings of MyType in the type expressions being compared.
We say that a type is monotonic in type identifier iff implies that for all not occurring in . For example, by our subtyping rules, the function type is monotonic in , but fails to be monotonic in .
A correct definition of subtyping for object types is:
if the two types are equivalent
or
Notice that the only difference between matching and subtyping is the addition of the second clause in the definition of subtyping. Thus if two object types are subtypes, they match, but not vice-versa. However, if all of the method types are monotonic in MyType, then the two types match iff they are subtypes.
is not a subtype of , because has a parameter of type MyType. However, . In contrast, there is no difficulty with subtyping in classes containing methods like the and methods discussed earlier, since MyType only occurs as the result type.
This new definition of subtypes for object types is based on the definition of subtyping for recursive types in [AC93], as type expressions with MyType can be interpreted as being implicitly recursively defined. The rules in that paper would actually allow more types to be subtypes than can be determined with the above rule. The reason is that the general rules given there allow arbitrary ``unfolding'' of recursively defined types. We do not allow that here because of complications that would arise in typing expressions. It is possible to strengthen the above definition by using the assumption to prove in the first part of the definition.