* 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
This commit is contained in:
shugo 2012-12-08 03:36:58 +00:00
Родитель d928280cb6
Коммит ee68f78c24
3 изменённых файлов: 19 добавлений и 4 удалений

Просмотреть файл

@ -1,3 +1,10 @@
Sat Dec 8 12:34:01 2012 Shugo Maeda <shugo@ruby-lang.org>
* 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 <shugo@ruby-lang.org>
* eval.c (rb_mod_refine): raise an ArgumentError if a given
@ -7,6 +14,8 @@ Sat Dec 8 11:59:59 2012 Shugo Maeda <shugo@ruby-lang.org>
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 <shugo@ruby-lang.org>
* eval.c (rb_mod_refine), vm_eval.c (rb_yield_refine_block):

Просмотреть файл

@ -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

Просмотреть файл

@ -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