From fc664d40132ce5f621f83c3178e90b7b73a612e6 Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 30 Sep 2009 04:15:46 +0000 Subject: * vm_method.c (rb_add_method_def): show the location where overwritten method was defined. [ruby-dev:39400] git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@25169 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- vm_method.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'vm_method.c') diff --git a/vm_method.c b/vm_method.c index 808c64c47..a879d0567 100644 --- a/vm_method.c +++ b/vm_method.c @@ -188,7 +188,26 @@ rb_add_method_def(VALUE klass, ID mid, rb_method_type_t type, rb_method_definiti old_def->alias_count == 0 && old_def->type != VM_METHOD_TYPE_UNDEF && old_def->type != VM_METHOD_TYPE_ZSUPER) { + extern rb_iseq_t *rb_proc_get_iseq(VALUE proc, int *is_proc); + rb_iseq_t *iseq = 0; + rb_warning("method redefined; discarding old %s", rb_id2name(mid)); + switch (old_def->type) { + case VM_METHOD_TYPE_ISEQ: + iseq = old_def->body.iseq; + break; + case VM_METHOD_TYPE_BMETHOD: + iseq = rb_proc_get_iseq(old_def->body.proc, 0); + break; + default: + break; + } + if (iseq && !NIL_P(iseq->filename)) { + int line = iseq->insn_info_table ? rb_iseq_first_lineno(iseq) : 0; + rb_compile_warning(RSTRING_PTR(iseq->filename), line, + "previous definition of %s was here", + rb_id2name(old_def->original_id)); + } } rb_free_method_entry(old_me); } -- cgit