@@ -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 ):
@@ -2926,8 +2925,8 @@ def is_trivial_self(t: CallableType) -> bool:
29262925 return False
29272926
29282927 prepend_self = (
2929- isinstance ( p_object_type , Instance )
2930- and has_any_type (p_object_type )
2928+ object_type is not None
2929+ and has_any_type (object_type )
29312930 and any (
29322931 typ .is_bound and typ .original_self_type is not None and not is_trivial_self (typ )
29332932 for typ in plausible_targets
@@ -2952,16 +2951,15 @@ def maybe_bind_self(t: Type) -> Type:
29522951 if prepend_self :
29532952 param = typ .original_self_type
29542953 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 )
2954+ typ = typ .copy_modified (
2955+ arg_types = [param ] + typ .arg_types ,
2956+ arg_kinds = [ARG_POS ] + typ .arg_kinds ,
2957+ arg_names = [None , * typ .arg_names ],
2958+ is_bound = False ,
2959+ original_self_type = None ,
2960+ )
29572961 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- ),
2962+ callee = typ ,
29652963 args = args ,
29662964 arg_kinds = arg_kinds ,
29672965 arg_names = arg_names ,
0 commit comments