@@ -2916,7 +2916,6 @@ def infer_overload_return_type(
29162916 # If we have a selftype overload, it should contribute to `any_causes_overload_ambiguity`
29172917 # check. Pretend that we're checking `Foo.func(instance, ...)` instead of
29182918 # `instance.func(...)`.
2919- p_object_type = get_proper_type (object_type ) if object_type is not None else None
29202919
29212920 def is_trivial_self (t : CallableType ) -> bool :
29222921 if isinstance (t .definition , FuncDef ):
@@ -2925,13 +2924,9 @@ def is_trivial_self(t: CallableType) -> bool:
29252924 return t .definition .func .is_trivial_self
29262925 return False
29272926
2928- prepend_self = (
2929- isinstance (p_object_type , Instance )
2930- and has_any_type (p_object_type )
2931- and any (
2932- typ .is_bound and typ .original_self_type is not None and not is_trivial_self (typ )
2933- for typ in plausible_targets
2934- )
2927+ prepend_self = has_any_type (object_type ) and any (
2928+ typ .is_bound and typ .original_self_type is not None and not is_trivial_self (typ )
2929+ for typ in plausible_targets
29352930 )
29362931 if prepend_self :
29372932 assert object_type is not None
@@ -2952,16 +2947,15 @@ def maybe_bind_self(t: Type) -> Type:
29522947 if prepend_self :
29532948 param = typ .original_self_type
29542949 assert param is not None , "Overload bound only partially?"
2955- assert isinstance (p_object_type , Instance )
2956- param = expand_type_by_instance (param , p_object_type )
2950+ typ = typ .copy_modified (
2951+ arg_types = [param ] + typ .arg_types ,
2952+ arg_kinds = [ARG_POS ] + typ .arg_kinds ,
2953+ arg_names = [None , * typ .arg_names ],
2954+ is_bound = False ,
2955+ original_self_type = None ,
2956+ )
29572957 ret_type , infer_type = self .check_call (
2958- callee = typ .copy_modified (
2959- arg_types = [param ] + typ .arg_types ,
2960- arg_kinds = [ARG_POS ] + typ .arg_kinds ,
2961- arg_names = [None , * typ .arg_names ],
2962- is_bound = False ,
2963- original_self_type = None ,
2964- ),
2958+ callee = typ ,
29652959 args = args ,
29662960 arg_kinds = arg_kinds ,
29672961 arg_names = arg_names ,
0 commit comments