Recommended way to introspect a Union type?

I want to introspect a union type. More concretely I want
a function that takes a type T of the form T = Union{X,Y}
and returns Set((X,Y)). I can do this like X = T.a and Y = T.b.
But that feels like internals. Is there an official way to do this?

I think such manipulations are officially discouraged, with T.a and T.b being the only way to access Union parts.

1 Like

Feature request on Julia’s issue tracker on Github:

1 Like