diff --git a/ChangeLog b/ChangeLog index 831bf30a8b..ff54d74902 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Fri Nov 9 10:43:55 2007 Nobuyoshi Nakada + + * eval.c (send_internal): use self in the previous frame to check for + protected methods. [ruby-core:13254] + + * insnhelper.ci (vm_call_method): send! method has gone. + Fri Nov 9 10:38:13 2007 Koichi Sasada * marshal.c (w_object): should be SPECIAL_CONST_P() instead of diff --git a/eval.c b/eval.c index e170dc6efa..acb2af19ba 100644 --- a/eval.c +++ b/eval.c @@ -1355,7 +1355,7 @@ method_missing(VALUE obj, ID id, int argc, const VALUE *argv, int call_status) } static VALUE -rb_call(VALUE klass, VALUE recv, ID mid, int argc, const VALUE *argv, int scope) +rb_call0(VALUE klass, VALUE recv, ID mid, int argc, const VALUE *argv, int scope, VALUE self) { NODE *body, *method; int noex; @@ -1409,8 +1409,7 @@ rb_call(VALUE klass, VALUE recv, ID mid, int argc, const VALUE *argv, int scope) defined_class = RBASIC(defined_class)->klass; } - if (!rb_obj_is_kind_of(rb_frame_self(), - rb_class_real(defined_class))) { + if (!rb_obj_is_kind_of(self, rb_class_real(defined_class))) { return method_missing(recv, mid, argc, argv, NOEX_PROTECTED); } } @@ -1442,6 +1441,12 @@ rb_call(VALUE klass, VALUE recv, ID mid, int argc, const VALUE *argv, int scope) } } +static VALUE +rb_call(VALUE klass, VALUE recv, ID mid, int argc, const VALUE *argv, int scope) +{ + return rb_call0(klass, recv, mid, argc, argv, scope, rb_frame_self()); +} + VALUE rb_apply(VALUE recv, ID mid, VALUE args) { @@ -1458,6 +1463,7 @@ static VALUE send_internal(int argc, VALUE *argv, VALUE recv, int scope) { VALUE vid; + VALUE self = RUBY_VM_PREVIOUS_CONTROL_FRAME(GET_THREAD()->cfp)->self; if (argc == 0) { rb_raise(rb_eArgError, "no method name given"); @@ -1465,7 +1471,7 @@ send_internal(int argc, VALUE *argv, VALUE recv, int scope) vid = *argv++; argc--; PASS_PASSED_BLOCK(); - return rb_call(CLASS_OF(recv), recv, rb_to_id(vid), argc, argv, scope); + return rb_call0(CLASS_OF(recv), recv, rb_to_id(vid), argc, argv, scope, self); } /* diff --git a/insnhelper.ci b/insnhelper.ci index c8d18ce4c8..bfbbe6f418 100644 --- a/insnhelper.ci +++ b/insnhelper.ci @@ -547,7 +547,7 @@ vm_call_method(rb_thread_t *th, rb_control_frame_t *cfp, val = vm_method_missing(th, id, recv, num, blockptr, stat); } else if (((mn->nd_noex & NOEX_MASK) & NOEX_PROTECTED) && - !(flag & VM_CALL_SEND_BANG_BIT)) { + !(flag & VM_CALL_SEND_BIT)) { VALUE defined_class = mn->nd_clss; if (TYPE(defined_class) == T_ICLASS) {