Project

General

Profile

0002-proc.c-original-arity.patch

proc.c: original arity - nobu (Nobuyoshi Nakada), 01/22/2013 04:29 PM

View differences:

proc.c
1743 1743
    return rb_method_entry_arity(data->me);
1744 1744
}
1745 1745

  
1746
static rb_method_entry_t *
1747
original_method_entry(VALUE mod, ID id)
1748
{
1749
    VALUE rclass;
1750
    rb_method_entry_t *me;
1751
    rb_method_definition_t *def;
1752
    while ((def = (me = rb_method_entry(mod, id, &rclass))->def) != 0 &&
1753
	   me->def->type == VM_METHOD_TYPE_ZSUPER) {
1754
	mod = RCLASS_SUPER(rclass);
1755
	id = me->def->original_id;
1756
    }
1757
    return me;
1758
}
1759

  
1746 1760
int
1747 1761
rb_mod_method_arity(VALUE mod, ID id)
1748 1762
{
1749
    rb_method_entry_t *me = rb_method_entry(mod, id, 0);
1763
    rb_method_entry_t *me = original_method_entry(mod, id);
1750 1764
    return rb_method_entry_arity(me);
1751 1765
}
1752 1766

  
test/ruby/test_marshal.rb
524 524
    end
525 525
  end
526 526

  
527
  class TestForRespondToZSuper < TestForRespondToFalse
528
    private :respond_to?
529
  end
530

  
527 531
  def test_marshal_respond_to_arity
528 532
    assert_nothing_raised(ArgumentError) do
529 533
      Marshal.dump(TestForRespondToFalse.new)
530 534
    end
535
    assert_nothing_raised(ArgumentError) do
536
      Marshal.dump(TestForRespondToZSuper.new)
537
    end
531 538
  end
532 539
end
533
-