def matches_signature(self, arg_types, is_var_arg, callee): """Determine whether argument types match the signature. If is_var_arg is True, the caller uses varargs. """ if not is_valid_argc(len(arg_types), False, callee): return False if is_var_arg: if not self.is_valid_var_arg(arg_types[-1]): return False arg_types, rest = expand_caller_var_args(arg_types, callee.max_fixed_args()) # Fixed function arguments. func_fixed = callee.max_fixed_args() for i in range(min(len(arg_types), func_fixed)): if not is_subtype(self.erase(arg_types[i]), self.erase( callee.arg_types[i])): return False # Function varargs. if callee.is_var_arg: for i in range(func_fixed, len(arg_types)): if not is_subtype(self.erase(arg_types[i]), self.erase(callee.arg_types[func_fixed])): return False return True
else: return match bool matches_signature(self, Typ[] arg_types, bool is_var_arg, Callable callee): """Determine whether argument types match the signature. If is_var_arg is True, the caller uses varargs. """ if not is_valid_argc(len(arg_types), False, callee): return False if is_var_arg: if not self.is_valid_var_arg(arg_types[-1]): return False arg_types, rest = expand_caller_var_args(arg_types, callee.max_fixed_args()) # Fixed function arguments. func_fixed = callee.max_fixed_args() for i in range(min(len(arg_types), func_fixed)): if not is_subtype(self.erase(arg_types[i]), self.erase( callee.arg_types[i])): return False # Function varargs. if callee.is_var_arg: for i in range(func_fixed, len(arg_types)): if not is_subtype(self.erase(arg_types[i]), self.erase(callee.arg_types[func_fixed])): return False return True