зеркало из https://github.com/github/ruby.git
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
This commit is contained in:
Родитель
218029f06d
Коммит
0fce0b7ba1
|
@ -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
|
||||
|
|
4
proc.c
4
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Загрузка…
Ссылка в новой задаче