isA method

  1. @override
bool isA(
  1. HTType? other
)
override

Check wether value of this HTType can be assigned to other HTType.

Implementation

@override
bool isA(HTType? other) {
  if (other == null) return true;

  if (other.isTop) return true;

  if (other.isBottom) return false;

  if (other is! HTStructuralType) return false;

  if (other.fieldTypes.isEmpty) {
    return true;
  } else {
    for (final key in other.fieldTypes.keys) {
      if (!fieldTypes.containsKey(key)) {
        return false;
      } else {
        if (fieldTypes[key]!.isNotA(other.fieldTypes[key])) {
          return false;
        }
      }
    }
    return true;
  }
}