diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-09-30 04:15:46 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-09-30 04:15:46 +0000 |
commit | fc664d40132ce5f621f83c3178e90b7b73a612e6 (patch) | |
tree | 93c3536ff19d3499e805a1e538e2f06694022fe5 /vm_method.c | |
parent | 4634eee316267fc6c37ab425e37470d3d0d6539a (diff) | |
download | ruby-fc664d40132ce5f621f83c3178e90b7b73a612e6.tar.gz ruby-fc664d40132ce5f621f83c3178e90b7b73a612e6.tar.xz ruby-fc664d40132ce5f621f83c3178e90b7b73a612e6.zip |
* 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
Diffstat (limited to 'vm_method.c')
-rw-r--r-- | vm_method.c | 19 |
1 files changed, 19 insertions, 0 deletions
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); } |