Determining if UnionAll corresponds to a single type + Union{}

Tuples are special because they are invariant covariant. In particular a tuple type is concrete if and only if all its parameters are concrete.

I think this means that a <:Tuple bound can only have one concrete tuple if and only if:

  • it’s not Vararg (so the number of parameters is known); and
  • each parameter bound only has one concrete subtype, so either:
    • it’s a concrete type, or
    • it’s bounded above by a concrete type, or
    • it’s bounded above by a type that only has one concrete subtype (and you can recurse on this condition if you like).

In practice you probably catch most cases without needing to recurse.

1 Like