module T::Private::Methods::CallValidation
def self.create_validator_method_medium2(mod, original_method, method_sig, original_visibility, return_type, arg0_type, arg1_type)
def self.create_validator_method_medium2(mod, original_method, method_sig, original_visibility, return_type, arg0_type, arg1_type) T::Private::ClassUtils.def_with_visibility(mod, method_sig.method_name, original_visibility) do |arg0, arg1, &blk| # This method is a manually sped-up version of more general code in `validate_call` unless arg0_type.valid?(arg0) CallValidation.report_error( method_sig, method_sig.arg_types[0][1].error_message_for_obj(arg0), 'Parameter', method_sig.arg_types[0][0], arg0_type, arg0, caller_offset: -1 ) end unless arg1_type.valid?(arg1) CallValidation.report_error( method_sig, method_sig.arg_types[1][1].error_message_for_obj(arg1), 'Parameter', method_sig.arg_types[1][0], arg1_type, arg1, caller_offset: -1 ) end # The following line breaks are intentional to show nice pry message # PRY note: # this code is sig validation code. # Please issue `finish` to step out of it return_value = original_method.bind(self).call(arg0, arg1, &blk) unless return_type.valid?(return_value) message = method_sig.return_type.error_message_for_obj(return_value) if message CallValidation.report_error( method_sig, message, 'Return value', nil, method_sig.return_type, return_value, caller_offset: -1 ) end end return_value end end