@@ -143,18 +143,15 @@ def is_enum_overlapping_union(x: ProperType, y: ProperType) -> bool:
143143 return (
144144 isinstance (x , Instance ) and x .type .is_enum and
145145 isinstance (y , UnionType ) and
146- all (isinstance (z , LiteralType ) and z .fallback .type == x .type # type: ignore[misc]
147- for z in y .items )
146+ all (x .type == p .fallback .type
147+ for p in (get_proper_type (z ) for z in y .relevant_items ())
148+ if isinstance (p , LiteralType ))
148149 )
149150
150151
151152def is_literal_in_union (x : ProperType , y : ProperType ) -> bool :
152- return (
153- isinstance (x , LiteralType ) and isinstance (y , UnionType ) and any (
154- isinstance (z , LiteralType ) and z == x # type: ignore[misc]
155- for z in y .items
156- )
157- )
153+ return (isinstance (x , LiteralType ) and isinstance (y , UnionType ) and
154+ any (x == get_proper_type (z ) for z in y .items ))
158155
159156
160157def is_overlapping_types (left : Type ,
@@ -223,10 +220,10 @@ def _is_overlapping_types(left: Type, right: Type) -> bool:
223220 # and crucially, we want to do that *fast* in case the enum is large
224221 # so we do it before expanding variants below to avoid O(n**2) behavior
225222 if (
226- is_enum_overlapping_union (left , right ) or
227- is_enum_overlapping_union (right , left ) or
228- is_literal_in_union (left , right ) or
229- is_literal_in_union (right , left )
223+ is_enum_overlapping_union (left , right )
224+ or is_enum_overlapping_union (right , left )
225+ or is_literal_in_union (left , right )
226+ or is_literal_in_union (right , left )
230227 ):
231228 return True
232229
0 commit comments