module T::Private::Methods::CallValidation

def self.create_validator_method_medium(mod, original_method, method_sig, original_visibility)

def self.create_validator_method_medium(mod, original_method, method_sig, original_visibility)
  if method_sig.return_type.is_a?(T::Private::Types::Void)
    raise 'Should have used create_validator_procedure_medium'
  end
  # trampoline to reduce stack frame size
  if method_sig.arg_types.empty?
    create_validator_method_medium0(mod, original_method, method_sig, original_visibility, method_sig.return_type)
  elsif method_sig.arg_types.length == 1
    create_validator_method_medium1(mod, original_method, method_sig, original_visibility, method_sig.return_type,
                                  method_sig.arg_types[0][1])
  elsif method_sig.arg_types.length == 2
    create_validator_method_medium2(mod, original_method, method_sig, original_visibility, method_sig.return_type,
                                  method_sig.arg_types[0][1],
                                  method_sig.arg_types[1][1])
  elsif method_sig.arg_types.length == 3
    create_validator_method_medium3(mod, original_method, method_sig, original_visibility, method_sig.return_type,
                                  method_sig.arg_types[0][1],
                                  method_sig.arg_types[1][1],
                                  method_sig.arg_types[2][1])
  elsif method_sig.arg_types.length == 4
    create_validator_method_medium4(mod, original_method, method_sig, original_visibility, method_sig.return_type,
                                  method_sig.arg_types[0][1],
                                  method_sig.arg_types[1][1],
                                  method_sig.arg_types[2][1],
                                  method_sig.arg_types[3][1])
  else
    raise 'should not happen'
  end
end