зеркало из https://github.com/github/ruby.git
* vm_insnhelper.c (vm_call_method): protected singleton methods should
be visible from same real class methods. [ruby-core:33506] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30064 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
bfcd4e5453
Коммит
adc978adc3
|
@ -1,3 +1,8 @@
|
|||
Fri Dec 3 12:17:19 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* vm_insnhelper.c (vm_call_method): protected singleton methods should
|
||||
be visible from same real class methods. [ruby-core:33506]
|
||||
|
||||
Fri Dec 3 07:08:42 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* ext/stringio/stringio.c (strio_getline): round upto next char
|
||||
|
|
|
@ -411,4 +411,23 @@ class TestMethod < Test::Unit::TestCase
|
|||
assert_nothing_raised { v.instance_eval { mv2 } }
|
||||
assert_nothing_raised { v.instance_eval { mv3 } }
|
||||
end
|
||||
|
||||
def test_protected_singleton
|
||||
bug4106 = '[ruby-core:33506]'
|
||||
a = Class.new do
|
||||
def meth
|
||||
:called
|
||||
end
|
||||
def test
|
||||
a = dup
|
||||
class << a
|
||||
protected :meth
|
||||
end
|
||||
a.meth
|
||||
end
|
||||
end.new
|
||||
called = nil
|
||||
assert_nothing_raised(NoMethodError, bug4106) {called = a.test}
|
||||
assert_equal(:called, called, bug4106)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -629,7 +629,10 @@ vm_call_method(rb_thread_t *th, rb_control_frame_t *cfp,
|
|||
else if (!(flag & VM_CALL_OPT_SEND_BIT) && (me->flag & NOEX_MASK) & NOEX_PROTECTED) {
|
||||
VALUE defined_class = me->klass;
|
||||
|
||||
if (TYPE(defined_class) == T_ICLASS) {
|
||||
if (FL_TEST(defined_class, FL_SINGLETON)) {
|
||||
defined_class = RCLASS_SUPER(defined_class);
|
||||
}
|
||||
else if (RB_TYPE_P(defined_class, T_ICLASS)) {
|
||||
defined_class = RBASIC(defined_class)->klass;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче