Skip to content

Commit

Permalink
Showing 2 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -830,6 +830,7 @@ public PublicNode(PublicNode prev) {
public RubyModule doPublic(RubyModule module, Object... args) {
notDesignedForCompilation();

module.visibilityMethod(this, args, Visibility.PUBLIC);
module.visibilityMethod(this, args, Visibility.PUBLIC);
return module;
}
19 changes: 17 additions & 2 deletions core/src/main/java/org/jruby/truffle/runtime/core/RubyModule.java
Original file line number Diff line number Diff line change
@@ -257,10 +257,25 @@ public void undefMethod(RubyNode currentNode, RubyMethod method) {
addMethod(currentNode, method.undefined());
}

/**
* Also searches on Object for modules.
* Used for alias_method, visibility changes, etc.
*/
private RubyMethod deepMethodSearch(String name) {
RubyMethod method = ModuleOperations.lookupMethod(this, name);

// Also search on Object if we are a Module. JRuby calls it deepMethodSearch().
if (method == null && !(this instanceof RubyClass)) { // TODO: handle undefined methods
method = ModuleOperations.lookupMethod(context.getCoreLibrary().getObjectClass(), name);
}

return method;
}

public void alias(RubyNode currentNode, String newName, String oldName) {
RubyNode.notDesignedForCompilation();

final RubyMethod method = ModuleOperations.lookupMethod(this, oldName);
RubyMethod method = deepMethodSearch(oldName);

if (method == null) {
CompilerDirectives.transferToInterpreter();
@@ -365,7 +380,7 @@ public void visibilityMethod(RubyNode currentNode, Object[] arguments, Visibilit
throw new UnsupportedOperationException();
}

final RubyMethod method = ModuleOperations.lookupMethod(this, methodName);
final RubyMethod method = deepMethodSearch(methodName);

if (method == null) {
throw new RuntimeException("Couldn't find method " + arg.toString());

0 comments on commit cd315fa

Please sign in to comment.