ruby-changes:30817
From: nobu <ko1@a...>
Date: Mon, 9 Sep 2013 16:56:09 +0900 (JST)
Subject: [ruby-changes:30817] nobu:r42896 (trunk): vm_method.c: clear cache after refine method
nobu 2013-09-09 16:56:02 +0900 (Mon, 09 Sep 2013) New Revision: 42896 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42896 Log: vm_method.c: clear cache after refine method * vm_method.c (rb_add_refined_method_entry): clear cache in the refined class since refining a method entry is modifying the class. [ruby-core:57079] [Bug #8880] Modified files: trunk/ChangeLog trunk/test/ruby/test_refinement.rb trunk/vm_method.c Index: ChangeLog =================================================================== --- ChangeLog (revision 42895) +++ ChangeLog (revision 42896) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Mon Sep 9 16:55:59 2013 Nobuyoshi Nakada <nobu@r...> + + * vm_method.c (rb_add_refined_method_entry): clear cache in the + refined class since refining a method entry is modifying the class. + [ruby-core:57079] [Bug #8880] + Mon Sep 9 09:14:58 2013 Nobuyoshi Nakada <nobu@r...> * tool/rbinstall.rb (Gem::Specification#initialize): default date to Index: vm_method.c =================================================================== --- vm_method.c (revision 42895) +++ vm_method.c (revision 42896) @@ -190,6 +190,7 @@ rb_add_refined_method_entry(VALUE refine https://github.com/ruby/ruby/blob/trunk/vm_method.c#L190 if (me) { make_method_entry_refined(me); + rb_clear_cache_by_class(refined_class); } else { rb_add_method(refined_class, mid, VM_METHOD_TYPE_REFINED, 0, Index: test/ruby/test_refinement.rb =================================================================== --- test/ruby/test_refinement.rb (revision 42895) +++ test/ruby/test_refinement.rb (revision 42896) @@ -982,6 +982,29 @@ class TestRefinement < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/ruby/test_refinement.rb#L982 RUBY end + def test_refine_after_using + assert_separately([], <<-"end;") + bug8880 = '[ruby-core:57079] [Bug #8880]' + module Test + refine(String) do + end + end + using Test + def t + 'Refinements are broken!'.chop! + end + t + module Test + refine(String) do + def chop! + self.sub!(/broken/, 'fine') + end + end + end + assert_equal('Refinements are fine!', t, bug8880) + end; + end + private def eval_using(mod, s) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/