From ee68f78c2462908882e3394f8a91631ec4a45beb Mon Sep 17 00:00:00 2001 From: shugo Date: Sat, 8 Dec 2012 03:36:58 +0000 Subject: * vm_insnhelper.c (vm_search_normal_superclass): super in a refinement always uses the refined class as its superclass. * test/ruby/test_refinement.rb: related test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38271 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 9 +++++++++ test/ruby/test_refinement.rb | 4 ++-- vm_insnhelper.c | 10 ++++++++-- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 198d9a131a..44fecd9490 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Sat Dec 8 12:34:01 2012 Shugo Maeda + + * vm_insnhelper.c (vm_search_normal_superclass): super in a + refinement always uses the refined class as its superclass. + + * test/ruby/test_refinement.rb: related test. + Sat Dec 8 11:59:59 2012 Shugo Maeda * eval.c (rb_mod_refine): raise an ArgumentError if a given @@ -7,6 +14,8 @@ Sat Dec 8 11:59:59 2012 Shugo Maeda cache to improve performance. It's safe now because blocks cannot be yielded with different refinements in the new specification. + * test/ruby/test_refinement.rb: related test. + Sat Dec 8 11:17:53 2012 Shugo Maeda * eval.c (rb_mod_refine), vm_eval.c (rb_yield_refine_block): diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb index 05ac1030c5..0d934d737e 100644 --- a/test/ruby/test_refinement.rb +++ b/test/ruby/test_refinement.rb @@ -115,10 +115,10 @@ class TestRefinement < Test::Unit::TestCase assert_equal("Foo#y", foo.y) end - def test_super_chain + def test_super_not_chained foo = Foo.new assert_equal("Foo#y", foo.y) - assert_equal("FooExt2#y FooExt#y Foo#y", FooExtClient2.invoke_y_on(foo)) + assert_equal("FooExt2#y Foo#y", FooExtClient2.invoke_y_on(foo)) assert_equal("Foo#y", foo.y) end diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 4d0d6b6185..5743654953 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -1866,8 +1866,14 @@ vm_call_super_method(rb_thread_t *th, rb_control_frame_t *reg_cfp, rb_call_info_ static inline VALUE vm_search_normal_superclass(VALUE klass) { - klass = RCLASS_ORIGIN(klass); - return RCLASS_SUPER(klass); + if (BUILTIN_TYPE(klass) == T_ICLASS && + FL_TEST(RBASIC(klass)->klass, RMODULE_IS_REFINEMENT)) { + return rb_refinement_module_get_refined_class(RBASIC(klass)->klass); + } + else { + klass = RCLASS_ORIGIN(klass); + return RCLASS_SUPER(klass); + } } static void -- cgit v1.2.3