merge revision(s) 43090,43091: [Backport #8966]

* vm_method.c (rb_undef): raise a NameError if the original method
	  of a refined method is not defined. 

	* vm_insnhelper.c (rb_method_entry_eq): added NULL check to avoid SEGV.

	* test/ruby/test_refinement.rb: related test.
	  of a refined method is not defined.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@43143 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nagachika 2013-10-04 17:13:11 +00:00
parent ea2c9da96f
commit 3cfa0074d9
4 changed files with 63 additions and 5 deletions

View file

@ -852,7 +852,9 @@ rb_undef(VALUE klass, ID id)
me = search_method(klass, id, 0);
if (UNDEFINED_METHOD_ENTRY_P(me)) {
if (UNDEFINED_METHOD_ENTRY_P(me) ||
(me->def->type == VM_METHOD_TYPE_REFINED &&
UNDEFINED_METHOD_ENTRY_P(me->def->body.orig_me))) {
const char *s0 = " class";
VALUE c = klass;
@ -1092,9 +1094,9 @@ rb_method_entry_eq(const rb_method_entry_t *m1, const rb_method_entry_t *m2)
static int
rb_method_definition_eq(const rb_method_definition_t *d1, const rb_method_definition_t *d2)
{
if (d1 && d1->type == VM_METHOD_TYPE_REFINED)
if (d1 && d1->type == VM_METHOD_TYPE_REFINED && d1->body.orig_me)
d1 = d1->body.orig_me->def;
if (d2 && d2->type == VM_METHOD_TYPE_REFINED)
if (d2 && d2->type == VM_METHOD_TYPE_REFINED && d2->body.orig_me)
d2 = d2->body.orig_me->def;
if (d1 == d2) return 1;
if (!d1 || !d2) return 0;