aboutsummaryrefslogtreecommitdiffstats
path: root/proc.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-04-03 06:57:43 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-04-03 06:57:43 +0000
commit1ab2c3ce8d6566d9ce03e39ac1a8a28cd5b2367a (patch)
treee219c38b67012575b2be9836908471a2054bdc5b /proc.c
parent97a78df13dc9b9823ed7b6b893de72799c18a615 (diff)
downloadruby-1ab2c3ce8d6566d9ce03e39ac1a8a28cd5b2367a.tar.gz
Fix Kernel#singleton_method with Module#Prepend
* proc.c (rb_obj_singleton_method): search the method entry from the origin class, for fix prepended modules. [Bug #14658] From: Vasiliy Ermolovich <younash@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63067 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'proc.c')
-rw-r--r--proc.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/proc.c b/proc.c
index 7134f68234..551a135e02 100644
--- a/proc.c
+++ b/proc.c
@@ -1771,11 +1771,11 @@ VALUE
rb_obj_singleton_method(VALUE obj, VALUE vid)
{
const rb_method_entry_t *me;
- VALUE klass;
+ VALUE klass = RCLASS_ORIGIN(rb_singleton_class_get(obj));
ID id = rb_check_id(&vid);
if (!id) {
- if (!NIL_P(klass = rb_singleton_class_get(obj)) &&
+ if (!NIL_P(klass) &&
respond_to_missing_p(klass, obj, vid, FALSE)) {
id = rb_intern_str(vid);
return mnew_missing(klass, obj, id, rb_cMethod);
@@ -1784,7 +1784,7 @@ rb_obj_singleton_method(VALUE obj, VALUE vid)
rb_name_err_raise("undefined singleton method `%1$s' for `%2$s'",
obj, vid);
}
- if (NIL_P(klass = rb_singleton_class_get(obj)) ||
+ if (NIL_P(klass) ||
UNDEFINED_METHOD_ENTRY_P(me = rb_method_entry_at(klass, id)) ||
UNDEFINED_REFINED_METHOD_P(me->def)) {
vid = ID2SYM(id);