Reflection API for Union types

Answer to 2) is Base.uniontypes though that isn’t exported

julia> Base.uniontypes(Union{Int, Nothing})
2-element Vector{Any}:
 Nothing
 Int64

You can find answers to a lot of questions about reflection in the ExprTools.jl package, in src/methods.jl because in the past i worked them out

1 Like