fix(match): enum literal narrowing is order-sensitive in match statements by Bahtya · Pull Request #21196 · python/mypy

@Bahtya

When matching a union containing Literal[SomeEnum.VALUE] and other types,
the order of match cases affected type narrowing results. Matching the
enum literal first (before other types) failed to narrow the subject type,
causing false positives with assert_never.

Root cause: visit_value_pattern used narrow_type_by_identity_equality with
'==' semantics, which has an overly-conservative enum ambiguity check for
StrEnum/IntEnum (since they can compare equal to str/int). In match
statements, this check is unnecessary when the other union members are
unrelated types.

Fix: For enum literal values without custom __eq__, bypass the identity
equality narrowing and use conditional_types_with_intersection directly,
which correctly narrows based on the literal value regardless of enum
base type ambiguity.

Fixes python#21187

Signed-off-by: bahtya <bahtyar153@qq.com>