Skip to content

Commit

Permalink
Add block-passing paths for Symbol#to_proc logic (1.9 behavior).
Browse files Browse the repository at this point in the history
  • Loading branch information
headius committed Mar 7, 2013
1 parent bf37b5b commit cb7c808
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/org/jruby/RubySymbol.java
Expand Up @@ -418,27 +418,42 @@ public IRubyObject to_proc(ThreadContext context) {
StaticScope scope = context.runtime.getStaticScopeFactory().getDummyScope();
final CallSite site = new FunctionalCachingCallSite(symbol);
BlockBody body = new ContextAwareBlockBody(scope, Arity.OPTIONAL, BlockBody.SINGLE_RESTARG) {
private IRubyObject yieldInner(ThreadContext context, RubyArray array) {
private IRubyObject yieldInner(ThreadContext context, RubyArray array, Block block) {
if (array.isEmpty()) {
throw context.runtime.newArgumentError("no receiver given");
}

IRubyObject self = array.shift(context);

return site.call(context, self, self, array.toJavaArray());
return site.call(context, self, self, array.toJavaArray(), block);
}

@Override
public IRubyObject yield(ThreadContext context, IRubyObject value, IRubyObject self,
RubyModule klass, boolean aValue, Binding binding, Block.Type type, Block block) {
RubyArray array = aValue && value instanceof RubyArray ?
(RubyArray) value : ArgsUtil.convertToRubyArray(context.runtime, value, false);

return yieldInner(context, array, block);
}

@Override
public IRubyObject yield(ThreadContext context, IRubyObject value,
Binding binding, Block.Type type, Block block) {
return yieldInner(context, ArgsUtil.convertToRubyArray(context.runtime, value, false), block);
}

@Override
public IRubyObject yield(ThreadContext context, IRubyObject value, Binding binding, Type type) {
return yieldInner(context, ArgsUtil.convertToRubyArray(context.runtime, value, false));
return yieldInner(context, ArgsUtil.convertToRubyArray(context.runtime, value, false), Block.NULL_BLOCK);
}

@Override
public IRubyObject yield(ThreadContext context, IRubyObject value, IRubyObject self, RubyModule klass, boolean aValue, Binding binding, Type type) {
RubyArray array = aValue && value instanceof RubyArray ?
(RubyArray) value : ArgsUtil.convertToRubyArray(context.runtime, value, false);

return yieldInner(context, array);
return yieldInner(context, array, Block.NULL_BLOCK);
}

@Override
Expand Down

0 comments on commit cb7c808

Please sign in to comment.