[前][次][番号順一覧][スレッド一覧]

ruby-changes:33028

From: naruse <ko1@a...>
Date: Sat, 22 Feb 2014 14:05:30 +0900 (JST)
Subject: [ruby-changes:33028] naruse:r45107 (ruby_2_1): merge revision(s) 44931: [Backport #9452]

naruse	2014-02-22 14:05:22 +0900 (Sat, 22 Feb 2014)

  New Revision: 45107

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=45107

  Log:
    merge revision(s) 44931: [Backport #9452]
    
    * vm_insnhelper.c (vm_call_method): should check ci->me->flag of
      a refining method in case the method is private.
      [ruby-core:60111] [Bug #9452]
    
    * vm_method.c (make_method_entry_refined): set me->flag of a refined
      method entry to NOEX_PUBLIC in case the original method is private
      and it is refined as a public method.  The original flag is stored
      in me->def->body.orig_me, so it's OK to make a refined method
      entry public.  [ruby-core:60111] [Bug #9452]
    
    * test/ruby/test_refinement.rb: related tests.

  Modified directories:
    branches/ruby_2_1/
  Modified files:
    branches/ruby_2_1/ChangeLog
    branches/ruby_2_1/test/ruby/test_refinement.rb
    branches/ruby_2_1/version.h
    branches/ruby_2_1/vm_insnhelper.c
    branches/ruby_2_1/vm_method.c
Index: ruby_2_1/ChangeLog
===================================================================
--- ruby_2_1/ChangeLog	(revision 45106)
+++ ruby_2_1/ChangeLog	(revision 45107)
@@ -1,3 +1,17 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/ChangeLog#L1
+Sat Feb 22 13:49:30 2014  Shugo Maeda  <shugo@r...>
+
+	* vm_insnhelper.c (vm_call_method): should check ci->me->flag of
+	  a refining method in case the method is private.
+	  [ruby-core:60111] [Bug #9452]
+
+	* vm_method.c (make_method_entry_refined): set me->flag of a refined
+	  method entry to NOEX_PUBLIC in case the original method is private
+	  and it is refined as a public method.  The original flag is stored
+	  in me->def->body.orig_me, so it's OK to make a refined method
+	  entry public.  [ruby-core:60111] [Bug #9452]
+
+	* test/ruby/test_refinement.rb: related tests.
+
 Sat Feb 22 13:26:57 2014  Nobuyoshi Nakada  <nobu@r...>
 
 	* iseq.c (iseq_load): keep type_map to get rid of memory leak.
Index: ruby_2_1/vm_method.c
===================================================================
--- ruby_2_1/vm_method.c	(revision 45106)
+++ ruby_2_1/vm_method.c	(revision 45107)
@@ -212,6 +212,7 @@ make_method_entry_refined(rb_method_entr https://github.com/ruby/ruby/blob/trunk/ruby_2_1/vm_method.c#L212
     *new_def->body.orig_me = *me;
     rb_vm_check_redefinition_opt_method(me, me->klass);
     if (me->def) me->def->alias_count++;
+    me->flag = NOEX_WITH_SAFE(NOEX_PUBLIC);
     me->def = new_def;
 }
 
Index: ruby_2_1/version.h
===================================================================
--- ruby_2_1/version.h	(revision 45106)
+++ ruby_2_1/version.h	(revision 45107)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/version.h#L1
 #define RUBY_VERSION "2.1.1"
 #define RUBY_RELEASE_DATE "2014-02-22"
-#define RUBY_PATCHLEVEL 52
+#define RUBY_PATCHLEVEL 53
 
 #define RUBY_RELEASE_YEAR 2014
 #define RUBY_RELEASE_MONTH 2
Index: ruby_2_1/vm_insnhelper.c
===================================================================
--- ruby_2_1/vm_insnhelper.c	(revision 45106)
+++ ruby_2_1/vm_insnhelper.c	(revision 45107)
@@ -1829,7 +1829,7 @@ vm_call_method(rb_thread_t *th, rb_contr https://github.com/ruby/ruby/blob/trunk/ruby_2_1/vm_insnhelper.c#L1829
 		    ci->me = me;
 		    ci->defined_class = defined_class;
 		    if (me->def->type != VM_METHOD_TYPE_REFINED) {
-			goto normal_method_dispatch;
+			goto start_method_dispatch;
 		    }
 		}
 
@@ -1838,11 +1838,8 @@ vm_call_method(rb_thread_t *th, rb_contr https://github.com/ruby/ruby/blob/trunk/ruby_2_1/vm_insnhelper.c#L1838
 		    ci->me = ci->me->def->body.orig_me;
 		    if (UNDEFINED_METHOD_ENTRY_P(ci->me)) {
 			ci->me = 0;
-			goto start_method_dispatch;
-		    }
-		    else {
-			goto normal_method_dispatch;
 		    }
+		    goto start_method_dispatch;
 		}
 		else {
 		    klass = ci->me->klass;
Index: ruby_2_1/test/ruby/test_refinement.rb
===================================================================
--- ruby_2_1/test/ruby/test_refinement.rb	(revision 45106)
+++ ruby_2_1/test/ruby/test_refinement.rb	(revision 45107)
@@ -1107,6 +1107,51 @@ class TestRefinement < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/ruby_2_1/test/ruby/test_refinement.rb#L1107
     INPUT
   end
 
+  def test_adding_private_method
+    bug9452 = '[ruby-core:60111] [Bug #9452]'
+
+    assert_in_out_err([], <<-INPUT, ["Success!", "NoMethodError"], [], bug9452)
+      module R
+        refine Object do
+          def m
+            puts "Success!"
+          end
+
+          private(:m)
+        end
+      end
+
+      using R
+
+      m
+      42.m rescue p($!.class)
+    INPUT
+  end
+
+  def test_making_private_method_public
+    bug9452 = '[ruby-core:60111] [Bug #9452]'
+
+    assert_in_out_err([], <<-INPUT, ["Success!", "Success!"], [], bug9452)
+        class Object
+          private
+          def m
+          end
+        end
+
+        module R
+          refine Object do
+            def m
+              puts "Success!"
+            end
+          end
+        end
+
+        using R
+        m
+        42.m
+    INPUT
+  end
+
   private
 
   def eval_using(mod, s)

Property changes on: ruby_2_1
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r44931


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]