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

ruby-changes:37565

From: naruse <ko1@a...>
Date: Thu, 19 Feb 2015 16:13:32 +0900 (JST)
Subject: [ruby-changes:37565] naruse:r49646 (ruby_2_2): merge revision(s) 49259: [Backport #10744]

naruse	2015-02-19 16:13:14 +0900 (Thu, 19 Feb 2015)

  New Revision: 49646

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

  Log:
    merge revision(s) 49259: [Backport #10744]
    
    * proc.c (rb_obj_singleton_method): Kernel#singleton_method should
      not use refinements, as well as Kernel#method.
      [ruby-core:67603] [Bug #10744]

  Modified directories:
    branches/ruby_2_2/
  Modified files:
    branches/ruby_2_2/ChangeLog
    branches/ruby_2_2/proc.c
    branches/ruby_2_2/test/ruby/test_refinement.rb
    branches/ruby_2_2/version.h
Index: ruby_2_2/ChangeLog
===================================================================
--- ruby_2_2/ChangeLog	(revision 49645)
+++ ruby_2_2/ChangeLog	(revision 49646)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ChangeLog#L1
+Thu Feb 19 16:07:03 2015  Seiei Higa  <hanachin@g...>
+
+	* proc.c (rb_obj_singleton_method): Kernel#singleton_method should
+	  not use refinements, as well as Kernel#method.
+	  [ruby-core:67603] [Bug #10744]
+
 Thu Feb 19 15:32:26 2015  Dave Stevens  <dave@c...>
 
 	* string.c (str_make_independent_expand): terminate String when
Index: ruby_2_2/proc.c
===================================================================
--- ruby_2_2/proc.c	(revision 49645)
+++ ruby_2_2/proc.c	(revision 49646)
@@ -1528,7 +1528,8 @@ rb_obj_singleton_method(VALUE obj, VALUE https://github.com/ruby/ruby/blob/trunk/ruby_2_2/proc.c#L1528
 			  QUOTE(vid), obj);
     }
     if (NIL_P(klass = rb_singleton_class_get(obj)) ||
-	!(me = rb_method_entry_at(klass, id))) {
+	UNDEFINED_METHOD_ENTRY_P(me = rb_method_entry_at(klass, id)) ||
+	UNDEFINED_REFINED_METHOD_P(me->def)) {
 	rb_name_error(id, "undefined singleton method `%"PRIsVALUE"' for `%"PRIsVALUE"'",
 		      QUOTE_ID(id), obj);
     }
@@ -2831,4 +2832,3 @@ Init_Binding(void) https://github.com/ruby/ruby/blob/trunk/ruby_2_2/proc.c#L2832
     rb_define_method(rb_cBinding, "receiver", bind_receiver, 0);
     rb_define_global_function("binding", rb_f_binding, 0);
 }
-
Index: ruby_2_2/version.h
===================================================================
--- ruby_2_2/version.h	(revision 49645)
+++ ruby_2_2/version.h	(revision 49646)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/version.h#L1
 #define RUBY_VERSION "2.2.0"
 #define RUBY_RELEASE_DATE "2015-02-19"
-#define RUBY_PATCHLEVEL 56
+#define RUBY_PATCHLEVEL 57
 
 #define RUBY_RELEASE_YEAR 2015
 #define RUBY_RELEASE_MONTH 2
Index: ruby_2_2/test/ruby/test_refinement.rb
===================================================================
--- ruby_2_2/test/ruby/test_refinement.rb	(revision 49645)
+++ ruby_2_2/test/ruby/test_refinement.rb	(revision 49646)
@@ -1217,6 +1217,24 @@ class TestRefinement < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/ruby_2_2/test/ruby/test_refinement.rb#L1217
     end;
   end
 
+  def test_singleton_method_should_not_use_refinements
+    assert_separately([], <<-"end;")
+    bug10744 = '[ruby-core:67603] [Bug #10744]'
+
+    class C
+    end
+
+    module RefinementBug
+      refine C.singleton_class do
+        def foo
+        end
+      end
+    end
+
+    assert_raise(NameError, bug10744) { C.singleton_method(:foo) }
+    end;
+  end
+
   def test_refined_method_defined
     assert_separately([], <<-"end;")
     bug10753 = '[ruby-core:67656] [Bug #10753]'

Property changes on: ruby_2_2
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r49259


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

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