<commit_before>class Module
  def alias_method(new_name, current_name)
    new_name = Type.coerce_to_symbol(new_name)
    current_name = Type.coerce_to_symbol(current_name)
    mod, entry = lookup_method(current_name)

    if entry
      # If we're aliasing a method we contain, just reference it directly, no
      # need for the alias wrapper
      if mod == self
        @method_table.store new_name, entry.method, entry.visibility
      else
        @method_table.alias new_name, entry.visibility, current_name,
                            entry.method, mod
      end

      Rubinius::VM.reset_method_cache(new_name)
    else
      if ai = __metaclass_object__
        raise NameError, "Unable to find '#{current_name}' for object #{ai.inspect}"
      else
        thing = kind_of?(Class) ? "class" : "module"
        raise NameError, "undefined method `#{current_name}' for #{thing} `#{self.name}'"
      end
    end
  end

  def module_function(*args)
    if args.empty?
      vs = Rubinius::VariableScope.of_sender
      if scr = vs.method.scope.script
        if scr.eval? and scr.eval_binding
          scr.eval_binding.variables.method_visibility = :module
        end
      end

      Rubinius::VariableScope.of_sender.method_visibility = :module
    else
      mc = Rubinius.object_metaclass(self)
      args.each do |meth|
        method_name = Type.coerce_to_symbol meth
        method = find_method_in_hierarchy(method_name)
        mc.method_table.store method_name, method.method, :public
        set_visibility method_name, :private
      end<commit_msg>Raise the right exception when alias fails in a module.<commit_after>class Module
  def alias_method(new_name, current_name)
    new_name = Type.coerce_to_symbol(new_name)
    current_name = Type.coerce_to_symbol(current_name)
    mod, entry = lookup_method(current_name)

    if entry
      # If we're aliasing a method we contain, just reference it directly, no
      # need for the alias wrapper
      if mod == self
        @method_table.store new_name, entry.method, entry.visibility
      else
        @method_table.alias new_name, entry.visibility, current_name,
                            entry.method, mod
      end

      Rubinius::VM.reset_method_cache(new_name)
    else
      if kind_of?(Class) && ai = __metaclass_object__
        raise NameError, "Unable to find '#{current_name}' for object #{ai.inspect}"
      else
        thing = kind_of?(Class) ? "class" : "module"
        raise NameError, "undefined method `#{current_name}' for #{thing} `#{self.name}'"
      end
    end
  end

  def module_function(*args)
    if args.empty?
      vs = Rubinius::VariableScope.of_sender
      if scr = vs.method.scope.script
        if scr.eval? and scr.eval_binding
          scr.eval_binding.variables.method_visibility = :module
        end
      end

      Rubinius::VariableScope.of_sender.method_visibility = :module
    else
      mc = Rubinius.object_metaclass(self)
      args.each do |meth|
        method_name = Type.coerce_to_symbol meth
        method = find_method_in_hierarchy(method_name)
        mc.method_table.store method_name, method.method, :public
        set_visibility method_name, :private
      end
{'fraction_non_alphanumeric': 0.08361934477379095, 'fraction_numerical': 0.0, 'mean_word_length': 2.7322467986030268, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1839829', 'n_tokens_mistral': 990, 'n_tokens_neox': 964, 'n_words': 237}