In Cool, every class name is also a type. In addition, there is a type SELF_TYPE that can be used in special circumstances.
A type declaration has the form x:C, where x is a variable and C is a type. Every variable must have a type declaration at the point it is introduced, whether that is in a let, case, or as the formal parameter of a method. The types of all attributes must also be declared.
The basic type rule in Cool is that if a method or variable expects a value of type P, then any value of type C may be used instead, provided that P is an ancestor of C in the class hierarchy. In other words, if C inherits from P, either directly or indirectly, then a C can be used wherever a P would suffice.
When an object of class C may be used in place of an object of class P, we say that C conforms to P or that C≤P (think: C is lower down in the inheritance tree). As discussed above, conformance is defined in terms of the inheritance graph.
Definition 4.1 (Conformance) Let A,C, and P be types.
Because Object is the root of the class hierarchy, it follows that A≤Object for all types A.