Skip to content

Commit

Permalink
Fill out port of check_funcall logic more completely.
Browse files Browse the repository at this point in the history
This may fix #1976.
  • Loading branch information
headius committed Sep 16, 2014
1 parent 44f83a9 commit 769b2c3
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions core/src/main/java/org/jruby/RubyClass.java
Expand Up @@ -622,7 +622,7 @@ public IRubyObject finvokeChecked(ThreadContext context, IRubyObject self, Strin
return null;

me = searchMethod(name);
if (!checkFuncallCallable(context, me)) {
if (!checkFuncallCallable(context, me, CallType.FUNCTIONAL, self)) {
return checkFuncallMissing(context, klass, self, name);
}
return me.call(context, self, klass, name);
Expand Down Expand Up @@ -665,9 +665,14 @@ private static boolean checkFuncallRespondTo(ThreadContext context, RubyClass kl
}

// MRI: check_funcall_callable
public static boolean checkFuncallCallable(ThreadContext context, DynamicMethod method) {
// FIXME: MRI actually checks protectedness here too
return !method.getVisibility().isPrivate();
public static boolean checkFuncallCallable(ThreadContext context, DynamicMethod method, CallType callType, IRubyObject self) {
return rbMethodCallStatus(context, method, callType, self);
}

// MRI: rb_method_call_status
// FIXME: Partial impl because we don't have these "NOEX" flags
public static boolean rbMethodCallStatus(ThreadContext context, DynamicMethod method, CallType callType, IRubyObject self) {
return !method.isUndefined() && method.isCallableFrom(self, callType);
}

private static IRubyObject checkFuncallMissing(ThreadContext context, RubyClass klass, IRubyObject self, String method, IRubyObject... args) {
Expand Down

0 comments on commit 769b2c3

Please sign in to comment.