diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-03-06 11:16:34 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-03-06 11:16:34 +0000 |
commit | 7fed9a2df50404c734504e0405ecaa98f0d9147c (patch) | |
tree | 19be6a0efc6648be92de6e03e4ff7666923782fc /proc.c | |
parent | a679e98e64a7c69d65578b11ef072e1115d536ad (diff) | |
download | ruby-7fed9a2df50404c734504e0405ecaa98f0d9147c.tar.gz |
proc.c: call respond_to_missing? with a symbol
[ruby-core:91683] [Bug #15640]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67185 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'proc.c')
-rw-r--r-- | proc.c | 21 |
1 files changed, 13 insertions, 8 deletions
@@ -1387,6 +1387,15 @@ mnew_missing(VALUE klass, VALUE obj, ID id, VALUE mclass) } static VALUE +mnew_missing_by_name(VALUE klass, VALUE obj, VALUE *name, int scope, VALUE mclass) +{ + VALUE vid = rb_str_intern(*name); + *name = vid; + if (!respond_to_missing_p(klass, obj, vid, scope)) return Qfalse; + return mnew_missing(klass, obj, SYM2ID(vid), mclass); +} + +static VALUE mnew_internal(const rb_method_entry_t *me, VALUE klass, VALUE iclass, VALUE obj, ID id, VALUE mclass, int scope, int error) { @@ -1690,10 +1699,8 @@ obj_method(VALUE obj, VALUE vid, int scope) const VALUE mclass = rb_cMethod; if (!id) { - if (respond_to_missing_p(klass, obj, vid, scope)) { - id = rb_intern_str(vid); - return mnew_missing(klass, obj, id, mclass); - } + VALUE m = mnew_missing_by_name(klass, obj, &vid, scope, mclass); + if (m) return m; rb_method_name_error(klass, vid); } return mnew(klass, obj, id, mclass, scope); @@ -1795,10 +1802,8 @@ rb_obj_singleton_method(VALUE obj, VALUE vid) obj, vid); } if (!id) { - if (respond_to_missing_p(klass, obj, vid, FALSE)) { - id = rb_intern_str(vid); - return mnew_missing(klass, obj, id, rb_cMethod); - } + VALUE m = mnew_missing_by_name(klass, obj, &vid, FALSE, rb_cMethod); + if (m) return m; goto undef; } me = rb_method_entry_at(klass, id); |