Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 078602e19e64
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 50402223b866
Choose a head ref
  • 3 commits
  • 2 files changed
  • 2 contributors

Commits on Feb 14, 2018

  1. Add MRI test for Module new public methods

    New public methods on Module class:
    
      - define_method
      - alias_method
      - undef_method
      - remove_method
    nomadium committed Feb 14, 2018
    Copy the full SHA
    7fcd1b4 View commit details
  2. Module#define_method, alias_method, undef_method, remove_method are n…

    …ow public
    
    For more information, please see feature #14133.
    nomadium committed Feb 14, 2018
    Copy the full SHA
    523123b View commit details

Commits on Feb 15, 2018

  1. Merge pull request #5047 from nomadium/module-methods-define-remove-a…

    …lias-undef-method-are-now-public
    
    Module#define_method, alias_method, undef_method, remove_method are now public
    enebo authored Feb 15, 2018
    Copy the full SHA
    5040222 View commit details
Showing with 12 additions and 8 deletions.
  1. +5 −5 core/src/main/java/org/jruby/RubyModule.java
  2. +7 −3 test/mri/ruby/test_module.rb
10 changes: 5 additions & 5 deletions core/src/main/java/org/jruby/RubyModule.java
Original file line number Diff line number Diff line change
@@ -1934,7 +1934,7 @@ public IRubyObject newMethod(IRubyObject receiver, final String methodName, bool
return newMethod;
}

@JRubyMethod(name = "define_method", visibility = PRIVATE, reads = VISIBILITY)
@JRubyMethod(name = "define_method", reads = VISIBILITY)
public IRubyObject define_method(ThreadContext context, IRubyObject arg0, Block block) {
Visibility visibility = getCurrentVisibilityForDefineMethod(context);

@@ -1985,7 +1985,7 @@ public IRubyObject defineMethodFromBlock(ThreadContext context, IRubyObject arg0
return nameSym;
}

@JRubyMethod(name = "define_method", visibility = PRIVATE, reads = VISIBILITY)
@JRubyMethod(name = "define_method", reads = VISIBILITY)
public IRubyObject define_method(ThreadContext context, IRubyObject arg0, IRubyObject arg1, Block block) {
Visibility visibility = getCurrentVisibilityForDefineMethod(context);

@@ -2837,7 +2837,7 @@ public RubyModule private_class_method(IRubyObject[] args) {
return this;
}

@JRubyMethod(name = "alias_method", required = 2, visibility = PRIVATE)
@JRubyMethod(name = "alias_method", required = 2)
public RubyModule alias_method(ThreadContext context, IRubyObject newId, IRubyObject oldId) {
String newName = newId.asJavaString();
defineAlias(newName, oldId.asJavaString());
@@ -2850,7 +2850,7 @@ public RubyModule alias_method(ThreadContext context, IRubyObject newId, IRubyOb
return this;
}

@JRubyMethod(name = "undef_method", rest = true, visibility = PRIVATE)
@JRubyMethod(name = "undef_method", rest = true)
public RubyModule undef_method(ThreadContext context, IRubyObject[] args) {
for (int i=0; i<args.length; i++) {
undef(context, args[i].asJavaString());
@@ -2909,7 +2909,7 @@ public IRubyObject module_exec(ThreadContext context, IRubyObject[] args, Block
}
}

@JRubyMethod(name = "remove_method", rest = true, visibility = PRIVATE)
@JRubyMethod(name = "remove_method", rest = true)
public RubyModule remove_method(ThreadContext context, IRubyObject[] args) {
for(int i=0;i<args.length;i++) {
removeMethod(context, TypeConverter.checkID(args[i]).toString());
10 changes: 7 additions & 3 deletions test/mri/ruby/test_module.rb
Original file line number Diff line number Diff line change
@@ -2038,6 +2038,10 @@ def test_public_methods
attr_accessor
attr_reader
attr_writer
define_method
alias_method
undef_method
remove_method
]
assert_equal public_methods.sort, (Module.public_methods & public_methods).sort
end
@@ -2104,9 +2108,9 @@ def test_singleton_class_ancestors

def test_visibility_by_public_class_method
bug8284 = '[ruby-core:54404] [Bug #8284]'
assert_raise(NoMethodError) {Object.define_method}
Module.new.public_class_method(:define_method)
assert_raise(NoMethodError, bug8284) {Object.define_method}
assert_raise(NoMethodError) {Object.remove_const}
Module.new.public_class_method(:remove_const)
assert_raise(NoMethodError, bug8284) {Object.remove_const}
end

def test_include_module_with_constants_does_not_invalidate_method_cache