зеркало из https://github.com/github/ruby.git
* vm_method.c (rb_add_method_def): show the location where
overwritten method was defined. [ruby-dev:39400] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25169 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
331fdbe822
Коммит
a71d47a380
|
@ -1,3 +1,8 @@
|
||||||
|
Wed Sep 30 13:15:45 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* vm_method.c (rb_add_method_def): show the location where
|
||||||
|
overwritten method was defined. [ruby-dev:39400]
|
||||||
|
|
||||||
Wed Sep 30 00:37:27 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Wed Sep 30 00:37:27 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* enumerator.c (enumerator_block_call): extracted.
|
* enumerator.c (enumerator_block_call): extracted.
|
||||||
|
|
8
proc.c
8
proc.c
|
@ -648,8 +648,10 @@ rb_proc_arity(VALUE self)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static rb_iseq_t *
|
#define get_proc_iseq rb_proc_get_iseq
|
||||||
get_proc_iseq(VALUE self, int *is_proc)
|
|
||||||
|
rb_iseq_t *
|
||||||
|
rb_proc_get_iseq(VALUE self, int *is_proc)
|
||||||
{
|
{
|
||||||
rb_proc_t *proc;
|
rb_proc_t *proc;
|
||||||
rb_iseq_t *iseq;
|
rb_iseq_t *iseq;
|
||||||
|
@ -894,7 +896,7 @@ mnew(VALUE klass, VALUE obj, ID id, VALUE mclass, int scope)
|
||||||
rb_method_definition_t *def = 0;
|
rb_method_definition_t *def = 0;
|
||||||
|
|
||||||
again:
|
again:
|
||||||
me = rb_method_entry(klass, id);
|
me = rb_method_entry(klass, id);
|
||||||
if (UNDEFINED_METHOD_ENTRY_P(me)) {
|
if (UNDEFINED_METHOD_ENTRY_P(me)) {
|
||||||
ID rmiss = rb_intern("respond_to_missing?");
|
ID rmiss = rb_intern("respond_to_missing?");
|
||||||
VALUE sym = ID2SYM(id);
|
VALUE sym = ID2SYM(id);
|
||||||
|
|
|
@ -106,6 +106,8 @@ class TestClass < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_method_redefinition
|
def test_method_redefinition
|
||||||
|
feature2155 = '[ruby-dev:39400]'
|
||||||
|
|
||||||
line = __LINE__+4
|
line = __LINE__+4
|
||||||
stderr = EnvUtil.verbose_warning do
|
stderr = EnvUtil.verbose_warning do
|
||||||
Class.new do
|
Class.new do
|
||||||
|
@ -114,6 +116,7 @@ class TestClass < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
assert_match(/:#{line}: warning: method redefined; discarding old foo/, stderr)
|
assert_match(/:#{line}: warning: method redefined; discarding old foo/, stderr)
|
||||||
|
assert_match(/:#{line-1}: warning: previous definition of foo/, stderr, feature2155)
|
||||||
|
|
||||||
stderr = EnvUtil.verbose_warning do
|
stderr = EnvUtil.verbose_warning do
|
||||||
Class.new do
|
Class.new do
|
||||||
|
@ -141,6 +144,7 @@ class TestClass < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
assert_match(/:#{line}: warning: method redefined; discarding old foo/, stderr)
|
assert_match(/:#{line}: warning: method redefined; discarding old foo/, stderr)
|
||||||
|
assert_match(/:#{line-1}: warning: previous definition of foo/, stderr, feature2155)
|
||||||
|
|
||||||
stderr = EnvUtil.verbose_warning do
|
stderr = EnvUtil.verbose_warning do
|
||||||
Class.new do
|
Class.new do
|
||||||
|
|
|
@ -788,6 +788,8 @@ class TestModule < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_method_redefinition
|
def test_method_redefinition
|
||||||
|
feature2155 = '[ruby-dev:39400]'
|
||||||
|
|
||||||
line = __LINE__+4
|
line = __LINE__+4
|
||||||
stderr = EnvUtil.verbose_warning do
|
stderr = EnvUtil.verbose_warning do
|
||||||
Module.new do
|
Module.new do
|
||||||
|
@ -796,6 +798,7 @@ class TestModule < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
assert_match(/:#{line}: warning: method redefined; discarding old foo/, stderr)
|
assert_match(/:#{line}: warning: method redefined; discarding old foo/, stderr)
|
||||||
|
assert_match(/:#{line-1}: warning: previous definition of foo/, stderr, feature2155)
|
||||||
|
|
||||||
stderr = EnvUtil.verbose_warning do
|
stderr = EnvUtil.verbose_warning do
|
||||||
Module.new do
|
Module.new do
|
||||||
|
@ -823,6 +826,7 @@ class TestModule < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
assert_match(/:#{line}: warning: method redefined; discarding old foo/, stderr)
|
assert_match(/:#{line}: warning: method redefined; discarding old foo/, stderr)
|
||||||
|
assert_match(/:#{line-1}: warning: previous definition of foo/, stderr, feature2155)
|
||||||
|
|
||||||
stderr = EnvUtil.verbose_warning do
|
stderr = EnvUtil.verbose_warning do
|
||||||
Module.new do
|
Module.new do
|
||||||
|
|
19
vm_method.c
19
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->alias_count == 0 &&
|
||||||
old_def->type != VM_METHOD_TYPE_UNDEF &&
|
old_def->type != VM_METHOD_TYPE_UNDEF &&
|
||||||
old_def->type != VM_METHOD_TYPE_ZSUPER) {
|
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));
|
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);
|
rb_free_method_entry(old_me);
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче