ruby-changes:38561
From: shugo <ko1@a...>
Date: Tue, 26 May 2015 22:16:31 +0900 (JST)
Subject: [ruby-changes:38561] shugo:r50642 (trunk): * vm_method.c (rb_alias): should resolve refined methods.
shugo 2015-05-26 22:16:18 +0900 (Tue, 26 May 2015) New Revision: 50642 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=50642 Log: * vm_method.c (rb_alias): should resolve refined methods. [ruby-core:69360] [Bug #11182] Modified files: trunk/ChangeLog trunk/test/ruby/test_refinement.rb trunk/vm_method.c Index: ChangeLog =================================================================== --- ChangeLog (revision 50641) +++ ChangeLog (revision 50642) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Tue May 26 22:10:43 2015 Shugo Maeda <shugo@r...> + + * vm_method.c (rb_alias): should resolve refined methods. + [ruby-core:69360] [Bug #11182] + Tue May 26 21:35:13 2015 Kazuhiro NISHIYAMA <zn@m...> * include/ruby/defines.h (RUBY_ATTR_ALLOC_SIZE): fix condition. Index: vm_method.c =================================================================== --- vm_method.c (revision 50641) +++ vm_method.c (revision 50642) @@ -1303,6 +1303,9 @@ rb_alias(VALUE klass, ID name, ID def) https://github.com/ruby/ruby/blob/trunk/vm_method.c#L1303 again: orig_me = search_method(klass, def, &defined_class); + if (orig_me && orig_me->def->type == VM_METHOD_TYPE_REFINED) { + orig_me = rb_resolve_refined_method(Qnil, orig_me, &defined_class); + } if (UNDEFINED_METHOD_ENTRY_P(orig_me) || UNDEFINED_REFINED_METHOD_P(orig_me->def)) { Index: test/ruby/test_refinement.rb =================================================================== --- test/ruby/test_refinement.rb (revision 50641) +++ test/ruby/test_refinement.rb (revision 50642) @@ -1455,6 +1455,32 @@ class TestRefinement < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/ruby/test_refinement.rb#L1455 } end + def test_alias_refined_method2 + bug11182 = '[ruby-core:69360]' + assert_in_out_err([], <<-INPUT, ["C"], [], bug11182) + class C + def foo + puts "C" + end + end + + module M + refine C do + def foo + puts "Refiend C" + end + end + end + + class D < C + alias bar foo + end + + using M + D.new.bar + INPUT + end + private def eval_using(mod, s) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/