summaryrefslogtreecommitdiffstats
path: root/vm_method.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-10-04 17:05:59 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-10-04 17:05:59 +0000
commit5b3c80abe258de5b889f5238fd2d2430c80281ff (patch)
treec60c9737334caa7bd635a073b790563cabb679b8 /vm_method.c
parent1895a5070488039d528b6b3fe5b4ceb8b8de9940 (diff)
downloadruby-5b3c80abe258de5b889f5238fd2d2430c80281ff.tar.gz
ruby-5b3c80abe258de5b889f5238fd2d2430c80281ff.tar.xz
ruby-5b3c80abe258de5b889f5238fd2d2430c80281ff.zip
* vm_method.c (basic_obj_respond_to): should not call
#respond_to_missing? for not implemented methods. [ruby-core:25909] * vm_method.c (rb_method_boundp): returns exceptional value 2 for not-implemented methods when called from #respond_to? (specifies by new contant NOEX_RESPONDS). * method.h (enum): new constant NOEX_RESPONDS added. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@25234 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_method.c')
-rw-r--r--vm_method.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/vm_method.c b/vm_method.c
index ec381c40d..a31fb8b5a 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -515,12 +515,14 @@ rb_method_boundp(VALUE klass, ID id, int ex)
if (ex && (me->flag & NOEX_PRIVATE)) {
return FALSE;
}
- if (!me->def || me->def->type == VM_METHOD_TYPE_NOTIMPLEMENTED) {
- return FALSE;
+ if (!me->def) return 0;
+ if (me->def->type == VM_METHOD_TYPE_NOTIMPLEMENTED) {
+ if (ex & NOEX_RESPONDS) return 2;
+ return 0;
}
- return TRUE;
+ return 1;
}
- return FALSE;
+ return 0;
}
void
@@ -1151,13 +1153,14 @@ basic_obj_respond_to(VALUE obj, ID id, int pub)
{
VALUE klass = CLASS_OF(obj);
- if (!rb_method_boundp(klass, id, pub)) {
- if (!rb_method_basic_definition_p(klass, respond_to_missing)) {
- return RTEST(rb_funcall(obj, respond_to_missing, pub ? 1 : 2, ID2SYM(id), Qtrue));
- }
+ switch (rb_method_boundp(klass, id, pub|NOEX_RESPONDS)) {
+ case 2:
return FALSE;
+ case 0:
+ return RTEST(rb_funcall(obj, respond_to_missing, pub ? 1 : 2, ID2SYM(id), Qtrue));
+ default:
+ return TRUE;
}
- return TRUE;
}
int