Fix narrowing of IntEnum and StrEnum types (#17874)
Fix regression introduced in #17866. It should still be possible to
narrow IntEnum and StrEnum types, but only when types match or are
disjoint. Add more logic to rule out narrowing when types are ambigous.