vm_insnhelper.c: fix zsuper in prepended
* vm_insnhelper.c (vm_call_method): a method entry refers the based class/module, so should search superclass from the origin i-class where the entry belongs to, to get rid of infinite loop when zsuper in a prepended class/module. [ruby-core:54105] [Bug #8238] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42724 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
4cdb8fd7ec
commit
74b85189b8
@ -1,3 +1,10 @@
|
|||||||
|
Thu Aug 29 17:03:10 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* vm_insnhelper.c (vm_call_method): a method entry refers the based
|
||||||
|
class/module, so should search superclass from the origin i-class
|
||||||
|
where the entry belongs to, to get rid of infinite loop when zsuper
|
||||||
|
in a prepended class/module. [ruby-core:54105] [Bug #8238]
|
||||||
|
|
||||||
Thu Aug 29 05:35:58 2013 Eric Hodel <drbrain@segment7.net>
|
Thu Aug 29 05:35:58 2013 Eric Hodel <drbrain@segment7.net>
|
||||||
|
|
||||||
* ext/zlib/zlib.c (zstream_run): Fix handling of deflate streams that
|
* ext/zlib/zlib.c (zstream_run): Fix handling of deflate streams that
|
||||||
|
@ -1527,6 +1527,21 @@ class TestModule < Test::Unit::TestCase
|
|||||||
assert_nothing_raised(NoMethodError, bug8005) {a.send :foo}
|
assert_nothing_raised(NoMethodError, bug8005) {a.send :foo}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_prepend_visibility_inherited
|
||||||
|
bug8238 = '[ruby-core:54105] [Bug #8238]'
|
||||||
|
assert_separately [], <<-"end;", timeout: 3
|
||||||
|
class A
|
||||||
|
def foo() A; end
|
||||||
|
private :foo
|
||||||
|
end
|
||||||
|
class B < A
|
||||||
|
public :foo
|
||||||
|
prepend Module.new
|
||||||
|
end
|
||||||
|
assert_equal(A, B.new.foo, "#{bug8238}")
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
|
||||||
def test_prepend_included_modules
|
def test_prepend_included_modules
|
||||||
bug8025 = '[ruby-core:53158] [Bug #8025]'
|
bug8025 = '[ruby-core:53158] [Bug #8025]'
|
||||||
mixin = labeled_module("mixin")
|
mixin = labeled_module("mixin")
|
||||||
|
@ -1769,6 +1769,8 @@ vm_call_method(rb_thread_t *th, rb_control_frame_t *cfp, rb_call_info_t *ci)
|
|||||||
start_method_dispatch:
|
start_method_dispatch:
|
||||||
if (ci->me != 0) {
|
if (ci->me != 0) {
|
||||||
if ((ci->me->flag == 0)) {
|
if ((ci->me->flag == 0)) {
|
||||||
|
VALUE klass;
|
||||||
|
|
||||||
normal_method_dispatch:
|
normal_method_dispatch:
|
||||||
switch (ci->me->def->type) {
|
switch (ci->me->def->type) {
|
||||||
case VM_METHOD_TYPE_ISEQ:{
|
case VM_METHOD_TYPE_ISEQ:{
|
||||||
@ -1801,10 +1803,10 @@ vm_call_method(rb_thread_t *th, rb_control_frame_t *cfp, rb_call_info_t *ci)
|
|||||||
return vm_call_bmethod(th, cfp, ci);
|
return vm_call_bmethod(th, cfp, ci);
|
||||||
}
|
}
|
||||||
case VM_METHOD_TYPE_ZSUPER:{
|
case VM_METHOD_TYPE_ZSUPER:{
|
||||||
VALUE klass;
|
klass = ci->me->klass;
|
||||||
|
klass = RCLASS_ORIGIN(klass);
|
||||||
zsuper_method_dispatch:
|
zsuper_method_dispatch:
|
||||||
klass = RCLASS_SUPER(ci->me->klass);
|
klass = RCLASS_SUPER(klass);
|
||||||
ci_temp = *ci;
|
ci_temp = *ci;
|
||||||
ci = &ci_temp;
|
ci = &ci_temp;
|
||||||
|
|
||||||
@ -1866,6 +1868,7 @@ vm_call_method(rb_thread_t *th, rb_control_frame_t *cfp, rb_call_info_t *ci)
|
|||||||
goto normal_method_dispatch;
|
goto normal_method_dispatch;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
klass = ci->me->klass;
|
||||||
goto zsuper_method_dispatch;
|
goto zsuper_method_dispatch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user