Skip to content
Permalink
Browse files
[Truffle] Add necessary handling of Dispath.MISSING when we use RETUR…
…N_MISSING behavior.
  • Loading branch information
eregon committed Dec 29, 2014
1 parent 6199915 commit 13e2779bd94481f1ea03aec9fb8749a9d07e0680
Showing with 4 additions and 3 deletions.
  1. +4 −3 core/src/main/java/org/jruby/truffle/nodes/cast/SplatCastNode.java
@@ -103,13 +103,14 @@ public RubyArray splat(VirtualFrame frame, Object object) {
method = "to_a";
}

// TODO(CS): why are we directly calling #respond_to? instead of using a respondsTo on a dispatch head node?
if (respondToCast.executeBoolean(frame, respondToToA.call(frame, object, "respond_to?", null, getContext().makeString(method), true))) {
// MRI tries to call dynamic respond_to? here.
Object respondToResult = respondToToA.call(frame, object, "respond_to?", null, getContext().makeString(method), true);
if (respondToResult != Dispatch.MISSING && respondToCast.executeBoolean(frame, respondToResult)) {
final Object array = toA.call(frame, object, method, null);

if (array instanceof RubyArray) {
return (RubyArray) array;
} else if (array instanceof RubyNilClass) {
} else if (array instanceof RubyNilClass || array == Dispatch.MISSING) {
return RubyArray.fromObject(getContext().getCoreLibrary().getArrayClass(), object);
} else {
throw new RaiseException(getContext().getCoreLibrary().typeErrorCantConvertTo(

0 comments on commit 13e2779

Please sign in to comment.