@@ -1876,23 +1876,6 @@ def check_method_override_for_base_with_name(
1876
1876
original_class_or_static = False # a variable can't be class or static
1877
1877
1878
1878
if isinstance (original_type , FunctionLike ):
1879
- active_self_type = self .scope .active_self_type ()
1880
- if isinstance (original_type , Overloaded ) and active_self_type :
1881
- # If we have an overload, filter to overloads that match the self type.
1882
- # This avoids false positives for concrete subclasses of generic classes,
1883
- # see testSelfTypeOverrideCompatibility for an example.
1884
- # It's possible we might want to do this as part of bind_and_map_method
1885
- filtered_items = [
1886
- item
1887
- for item in original_type .items
1888
- if not item .arg_types or is_subtype (active_self_type , item .arg_types [0 ])
1889
- ]
1890
- # If we don't have any filtered_items, maybe it's always a valid override
1891
- # of the superclass? However if you get to that point you're in murky type
1892
- # territory anyway, so we just preserve the type and have the behaviour match
1893
- # that of older versions of mypy.
1894
- if filtered_items :
1895
- original_type = Overloaded (filtered_items )
1896
1879
original_type = self .bind_and_map_method (base_attr , original_type , defn .info , base )
1897
1880
if original_node and is_property (original_node ):
1898
1881
original_type = get_property_type (original_type )
@@ -1964,10 +1947,28 @@ def bind_and_map_method(
1964
1947
is_class_method = sym .node .func .is_class
1965
1948
else :
1966
1949
is_class_method = sym .node .is_class
1967
- bound = bind_self (typ , self .scope .active_self_type (), is_class_method )
1950
+
1951
+ mapped_typ = cast (FunctionLike , map_type_from_supertype (typ , sub_info , super_info ))
1952
+ active_self_type = self .scope .active_self_type ()
1953
+ if isinstance (mapped_typ , Overloaded ) and active_self_type :
1954
+ # If we have an overload, filter to overloads that match the self type.
1955
+ # This avoids false positives for concrete subclasses of generic classes,
1956
+ # see testSelfTypeOverrideCompatibility for an example.
1957
+ filtered_items = [
1958
+ item
1959
+ for item in mapped_typ .items
1960
+ if not item .arg_types or is_subtype (active_self_type , item .arg_types [0 ])
1961
+ ]
1962
+ # If we don't have any filtered_items, maybe it's always a valid override
1963
+ # of the superclass? However if you get to that point you're in murky type
1964
+ # territory anyway, so we just preserve the type and have the behaviour match
1965
+ # that of older versions of mypy.
1966
+ if filtered_items :
1967
+ mapped_typ = Overloaded (filtered_items )
1968
+
1969
+ return bind_self (mapped_typ , active_self_type , is_class_method )
1968
1970
else :
1969
- bound = typ
1970
- return cast (FunctionLike , map_type_from_supertype (bound , sub_info , super_info ))
1971
+ return cast (FunctionLike , map_type_from_supertype (typ , sub_info , super_info ))
1971
1972
1972
1973
def get_op_other_domain (self , tp : FunctionLike ) -> Type | None :
1973
1974
if isinstance (tp , CallableType ):
0 commit comments