mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* vm_insnhelper.c (vm_call_method): __send__ can call protected
methods. [ruby-core:24500] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24280 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
34df0e5c9f
commit
00d61f1fe5
3 changed files with 29 additions and 2 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Sun Jul 26 18:30:02 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* vm_insnhelper.c (vm_call_method): __send__ can call protected
|
||||||
|
methods. [ruby-core:24500]
|
||||||
|
|
||||||
Sun Jul 26 01:09:14 2009 Alexander Zavorine <alexandre.zavorine@nokia.com>
|
Sun Jul 26 01:09:14 2009 Alexander Zavorine <alexandre.zavorine@nokia.com>
|
||||||
|
|
||||||
* ext/bigdecimal.c: moved BASE_FIG definition before it is used
|
* ext/bigdecimal.c: moved BASE_FIG definition before it is used
|
||||||
|
|
|
@ -104,12 +104,15 @@ class TestModule < Test::Unit::TestCase
|
||||||
private_class_method :cm1, "cm3"
|
private_class_method :cm1, "cm3"
|
||||||
|
|
||||||
def aClass
|
def aClass
|
||||||
|
:aClass
|
||||||
end
|
end
|
||||||
|
|
||||||
def aClass1
|
def aClass1
|
||||||
|
:aClass1
|
||||||
end
|
end
|
||||||
|
|
||||||
def aClass2
|
def aClass2
|
||||||
|
:aClass2
|
||||||
end
|
end
|
||||||
|
|
||||||
private :aClass1
|
private :aClass1
|
||||||
|
@ -118,15 +121,18 @@ class TestModule < Test::Unit::TestCase
|
||||||
|
|
||||||
class BClass < AClass
|
class BClass < AClass
|
||||||
def bClass1
|
def bClass1
|
||||||
|
:bClass1
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def bClass2
|
def bClass2
|
||||||
|
:bClass2
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
def bClass3
|
def bClass3
|
||||||
|
:bClass3
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -489,7 +495,7 @@ class TestModule < Test::Unit::TestCase
|
||||||
|
|
||||||
c = Class.new
|
c = Class.new
|
||||||
assert_raise(NameError) do
|
assert_raise(NameError) do
|
||||||
c.instance_eval { attr_reader :"$" }
|
c.instance_eval { attr_reader :"." }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -721,4 +727,18 @@ class TestModule < Test::Unit::TestCase
|
||||||
}.call
|
}.call
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_send
|
||||||
|
a = AClass.new
|
||||||
|
assert_equal(:aClass, a.__send__(:aClass))
|
||||||
|
assert_equal(:aClass1, a.__send__(:aClass1))
|
||||||
|
assert_equal(:aClass2, a.__send__(:aClass2))
|
||||||
|
b = BClass.new
|
||||||
|
assert_equal(:aClass, b.__send__(:aClass))
|
||||||
|
assert_equal(:aClass1, b.__send__(:aClass1))
|
||||||
|
assert_equal(:aClass2, b.__send__(:aClass2))
|
||||||
|
assert_equal(:bClass1, b.__send__(:bClass1))
|
||||||
|
assert_equal(:bClass2, b.__send__(:bClass2))
|
||||||
|
assert_equal(:bClass3, b.__send__(:bClass3))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -496,6 +496,7 @@ vm_call_method(rb_thread_t *th, rb_control_frame_t *cfp,
|
||||||
ID id, const rb_method_entry_t *me, VALUE recv)
|
ID id, const rb_method_entry_t *me, VALUE recv)
|
||||||
{
|
{
|
||||||
VALUE val;
|
VALUE val;
|
||||||
|
int opt_send = 0;
|
||||||
|
|
||||||
start_method_dispatch:
|
start_method_dispatch:
|
||||||
|
|
||||||
|
@ -567,6 +568,7 @@ vm_call_method(rb_thread_t *th, rb_control_frame_t *cfp,
|
||||||
num -= 1;
|
num -= 1;
|
||||||
DEC_SP(1);
|
DEC_SP(1);
|
||||||
flag |= VM_CALL_FCALL_BIT;
|
flag |= VM_CALL_FCALL_BIT;
|
||||||
|
opt_send = 1;
|
||||||
|
|
||||||
goto start_method_dispatch;
|
goto start_method_dispatch;
|
||||||
}
|
}
|
||||||
|
@ -605,7 +607,7 @@ vm_call_method(rb_thread_t *th, rb_control_frame_t *cfp,
|
||||||
}
|
}
|
||||||
val = vm_method_missing(th, id, recv, num, blockptr, stat);
|
val = vm_method_missing(th, id, recv, num, blockptr, stat);
|
||||||
}
|
}
|
||||||
else if ((me->flag & NOEX_MASK) & NOEX_PROTECTED) {
|
else if (!opt_send && (me->flag & NOEX_MASK) & NOEX_PROTECTED) {
|
||||||
VALUE defined_class = me->klass;
|
VALUE defined_class = me->klass;
|
||||||
|
|
||||||
if (TYPE(defined_class) == T_ICLASS) {
|
if (TYPE(defined_class) == T_ICLASS) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue