Example #1
0
// The subtype is a tuple, the supertype could be anything.
static bool is_tuple_subtype(ast_t* sub, ast_t* super)
{
  switch(ast_id(super))
  {
    case TK_NOMINAL:
      // A tuple can never be a strict subtype of a nominal type.
      return false;

    case TK_TYPEPARAMREF:
      // A tuple can never be a strict subtype of a type parameter.
      return false;

    case TK_UNIONTYPE:
      return is_subtype_union(sub, super);

    case TK_ISECTTYPE:
      return is_subtype_isect(sub, super);

    case TK_TUPLETYPE:
      return is_tuple_sub_tuple(sub, super);

    case TK_ARROW:
      return is_subtype_arrow(sub, super);

    default: {}
  }

  return false;
}
Example #2
0
static bool is_tuple_sub_x(ast_t* sub, ast_t* super, errorframe_t* errors)
{
  switch(ast_id(super))
  {
    case TK_UNIONTYPE:
      return is_x_sub_union(sub, super, errors);

    case TK_ISECTTYPE:
      return is_x_sub_isect(sub, super, errors);

    case TK_TUPLETYPE:
      return is_tuple_sub_tuple(sub, super, errors);

    case TK_NOMINAL:
    case TK_TYPEPARAMREF:
    case TK_ARROW:
      return is_tuple_sub_single(sub, super, errors);

    default: {}
  }

  assert(0);
  return false;
}