Skip to content

Commit

Permalink
Showing 3 changed files with 24 additions and 5 deletions.
10 changes: 9 additions & 1 deletion core/src/main/java/org/jruby/RubyProc.java
Original file line number Diff line number Diff line change
@@ -243,7 +243,15 @@ public static IRubyObject[] prepareProcArgs(ThreadContext context, Arity arity,
if (arity != Arity.ONE_ARGUMENT && required != 0 &&
(isFixed || arity != Arity.OPTIONAL) &&
actual == 1 && args[0].respondsTo("to_ary")) {
args = args[0].convertToArray().toJavaArray();
IRubyObject newAry = Helpers.aryToAry(args[0]);

if (newAry.isNil()) {
args = new IRubyObject[] { args[0] };
} else if (newAry instanceof RubyArray){
args = ((RubyArray) newAry).toJavaArray();
} else {
throw context.runtime.newTypeError(args[0].getType().getName() + "#to_ary should return Array");
}
actual = args.length;
}

2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/ast/util/ArgsUtil.java
Original file line number Diff line number Diff line change
@@ -49,7 +49,7 @@ public static IRubyObject[] convertToJavaArray(IRubyObject value) {
if (value instanceof RubyArray) {
return ((RubyArray)value).toJavaArrayMaybeUnsafe();
}

return new IRubyObject[] { value };
}

17 changes: 14 additions & 3 deletions core/src/main/java/org/jruby/runtime/Helpers.java
Original file line number Diff line number Diff line change
@@ -307,7 +307,7 @@ rubyName, containingClass, new SimpleSourcePosition(filename, line), arity, scop
callConfig,
parameterDesc);

addInstanceMethod(containingClass, rubyName, method, visibility,context, runtime);
addInstanceMethod(containingClass, rubyName, method, visibility, context, runtime);

return runtime.getNil();
}
@@ -968,7 +968,7 @@ public static IRubyObject isExceptionHandled(RubyException currentException, IRu
}

public static IRubyObject isExceptionHandled(RubyException currentException, IRubyObject exception, ThreadContext context) {
return isExceptionHandled((IRubyObject)currentException, exception, context);
return isExceptionHandled((IRubyObject) currentException, exception, context);
}

public static IRubyObject isExceptionHandled(IRubyObject currentException, IRubyObject exception, ThreadContext context) {
@@ -2840,7 +2840,18 @@ public static boolean needsSplat19(int requiredCount, boolean isRest) {
public static IRubyObject[] restructureBlockArgs19(IRubyObject value, Arity arity, Block.Type type, boolean needsSplat, boolean alreadyArray) {
if (!type.checkArity && arity == Arity.NO_ARGUMENTS) return IRubyObject.NULL_ARRAY;

if (value != null && !(value instanceof RubyArray) && needsSplat) value = Helpers.aryToAry(value);
if (value != null && !(value instanceof RubyArray) && needsSplat) {
// This is a little ugly but so much flows through here I decided to potentially replicate a little
// logic here to minimize chance of breaking anything.
IRubyObject newAry = Helpers.aryToAry(value);
if (newAry.isNil()) {
return new IRubyObject[] { value };
} else if (newAry instanceof RubyArray){
value = newAry;
} else {
throw value.getRuntime().newTypeError(value.getType().getName() + "#to_ary should return Array");
}
}

IRubyObject[] parameters;
if (value == null) {

0 comments on commit b7e6461

Please sign in to comment.