summaryrefslogtreecommitdiff
path: root/vm_method.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-02-06 04:35:23 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-02-06 04:35:23 +0000
commit6eb76ba664a7ea1dc2b6804a0f2280e1f7531c53 (patch)
tree3a74a76375a9ec16d64e36f381459003268ee95c /vm_method.c
parentfe072cef25054cce460c92408f3f8fe9cb2b5c0d (diff)
vm_method.c: show respond_to location
* proc.c (rb_method_entry_location, rb_{mod,obj}_method_location): new functions to obtain source location of method definition. * vm_method.c (rb_obj_respond_to): show the location of old style respond_to? method. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39089 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_method.c')
-rw-r--r--vm_method.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/vm_method.c b/vm_method.c
index f2c361f521..a82ba5faea 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -1529,13 +1529,22 @@ rb_obj_respond_to(VALUE obj, ID id, int priv)
if (rb_obj_method_arity(obj, idRespond_to) != 1) {
argc = 2;
}
- else {
+ else if (!NIL_P(ruby_verbose)) {
VALUE klass = CLASS_OF(obj);
+ VALUE location = rb_mod_method_location(klass, idRespond_to);
rb_warn("%"PRIsVALUE"%c""respond_to?(:%"PRIsVALUE") is"
" old fashion which takes only one parameter",
(FL_TEST(klass, FL_SINGLETON) ? obj : klass),
(FL_TEST(klass, FL_SINGLETON) ? '.' : '#'),
QUOTE_ID(id));
+ if (!NIL_P(location)) {
+ VALUE path = RARRAY_PTR(location)[0];
+ VALUE line = RARRAY_PTR(location)[1];
+ if (!NIL_P(path)) {
+ rb_compile_warn(RSTRING_PTR(path), NUM2INT(line),
+ "respond_to? is defined here");
+ }
+ }
}
}
return RTEST(rb_funcall2(obj, idRespond_to, argc, args));