Subtype relation

If object a inherits from b, a is a subtype of b. This subtype relation is extended to the types var, ref, ptr:

  1. proc isSubtype(a, b: PType): bool =
  2. if a.kind == b.kind:
  3. case a.kind
  4. of object:
  5. var aa = a.baseType
  6. while aa != nil and aa != b: aa = aa.baseType
  7. result = aa == b
  8. of var, ref, ptr:
  9. result = isSubtype(a.baseType, b.baseType)