ruby-changes:37103
From: nobu <ko1@a...>
Date: Thu, 8 Jan 2015 17:05:22 +0900 (JST)
Subject: [ruby-changes:37103] nobu:r49184 (trunk): vm_method.c: no super klass, no original method entry
nobu 2015-01-08 17:05:03 +0900 (Thu, 08 Jan 2015) New Revision: 49184 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=49184 Log: vm_method.c: no super klass, no original method entry * vm_method.c (rb_method_entry): if no super class, no original method entry. [ruby-core:67389] [Bug #10707] Modified files: trunk/ChangeLog trunk/test/ruby/test_refinement.rb trunk/vm_method.c Index: ChangeLog =================================================================== --- ChangeLog (revision 49183) +++ ChangeLog (revision 49184) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Thu Jan 8 17:05:00 2015 Seiei Higa <hanachin@g...> + + * vm_method.c (rb_method_entry): if no super class, no original + method entry. [ruby-core:67389] [Bug #10707] + Thu Jan 8 16:31:43 2015 Seiei Higa <hanachin@g...> * vm_method.c (rb_export_method): bail out if the original method Index: vm_method.c =================================================================== --- vm_method.c (revision 49183) +++ vm_method.c (revision 49184) @@ -668,12 +668,17 @@ get_original_method_entry(VALUE refineme https://github.com/ruby/ruby/blob/trunk/vm_method.c#L668 const rb_method_entry_t *me, VALUE *defined_class_ptr) { + VALUE super; + if (me->def->body.orig_me) { return me->def->body.orig_me; } + else if (!(super = RCLASS_SUPER(me->klass))) { + return 0; + } else { rb_method_entry_t *tmp_me; - tmp_me = rb_method_entry(RCLASS_SUPER(me->klass), me->called_id, + tmp_me = rb_method_entry(super, me->called_id, defined_class_ptr); return rb_resolve_refined_method(refinements, tmp_me, defined_class_ptr); Index: test/ruby/test_refinement.rb =================================================================== --- test/ruby/test_refinement.rb (revision 49183) +++ test/ruby/test_refinement.rb (revision 49184) @@ -1163,6 +1163,19 @@ class TestRefinement < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/ruby/test_refinement.rb#L1163 assert_raise(NoMethodError, bug10106) {Object.new.foo} end; + + assert_separately([], <<-"end;") + bug10707 = '[ruby-core:67389] [Bug #10707]' + module RefinementBug + refine BasicObject do + def foo + end + end + end + + assert(methods, bug10707) + assert_raise(NameError, bug10707) {method(:foo)} + end; end def test_change_refined_new_method_visibility -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/