That’s not possible. The type must be specified in one definition all at once, during which you can only give it 1 named supertype possibly parameterized by a subset of its type parameters (default to <: Any). I don’t know why exactly parametric types aren’t allowed to branch to different named supertypes, but it’d obviously make dispatch, type inference, and writing generics more complicated than it already is.
AFAIK, this isn’t a fundamental characteristic for keys(::Dict):
help?> keys(::Dict)
keys(a::AbstractDict)
Return an iterator over all keys in a dictionary.
collect(keys(a)) returns an array of keys. When the keys
are stored internally in a hash table, as is the case for
Dict, the order in which they are returned may vary. But
keys(a), values(a) and pairs(a) all iterate a and return
the elements in the same order.