summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-01-15 12:35:00 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-01-15 12:35:00 +0000
commit0fce0b7ba1337b25d717fc39481eef556d247005 (patch)
tree6727d5c8dd30f8fced14eccdf53d0aa722de4262
parent218029f06d0a43befac4a899dbeb302f901142ed (diff)
proc.c: singleton_method should not use refinements
* proc.c (rb_obj_singleton_method): Kernel#singleton_method should not use refinements, as well as Kernel#method. [ruby-core:67603] [Bug #10744] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49259 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--proc.c4
-rw-r--r--test/ruby/test_refinement.rb18
3 files changed, 26 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 8b963e5..3e4bb45 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Thu Jan 15 21:34:57 2015 Seiei Higa <hanachin@gmail.com>
+
+ * proc.c (rb_obj_singleton_method): Kernel#singleton_method should
+ not use refinements, as well as Kernel#method.
+ [ruby-core:67603] [Bug #10744]
+
Thu Jan 15 10:45:04 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
* array.c (rb_ary_select_bang, ary_reject_bang): linear
diff --git a/proc.c b/proc.c
index 805f7b9..48d7dcb 100644
--- a/proc.c
+++ b/proc.c
@@ -1528,7 +1528,8 @@ rb_obj_singleton_method(VALUE obj, VALUE vid)
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)
rb_define_method(rb_cBinding, "receiver", bind_receiver, 0);
rb_define_global_function("binding", rb_f_binding, 0);
}
-
diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb
index 884d031..596c679 100644
--- a/test/ruby/test_refinement.rb
+++ b/test/ruby/test_refinement.rb
@@ -1217,6 +1217,24 @@ class TestRefinement < Test::Unit::TestCase
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
+
private
def eval_using(mod, s)