fromtypingimportUnion, AnyclassA():
deffoo(self, x: Any) ->None: passclassB():
deffoo(self, x: str) ->None: passdeff(c: Union[A, B]) ->None:
reveal_type(c.foo) # E: Revealed type is 'def (x: Any)'defg(c: Union[B, A]) ->None:
reveal_type(c.foo) # E: Revealed type is 'def (x: builtins.str)'
Prior to #1989 the order of processing was reversed, which is how this bug was discovered. I think what's going on is that Callable[[Any], None] is compatible with Callable[[str], None] and vice-versa, so our "is_subtype" check is combining them.
One possible resolution is to only combine identical types in make_simplified_union, not "subtypes".
Prior to #1989 the order of processing was reversed, which is how this bug was discovered. I think what's going on is that
Callable[[Any], None]is compatible withCallable[[str], None]and vice-versa, so our "is_subtype" check is combining them.One possible resolution is to only combine identical types in
make_simplified_union, not "subtypes".