зеркало из https://github.com/github/ruby.git
Warn the defined location as deprecation as well as the main message
[Bug #17575]
This commit is contained in:
Родитель
62283f7a7a
Коммит
8dfae85adb
|
@ -258,6 +258,23 @@ class TestDefined < Test::Unit::TestCase
|
|||
assert_separately([], "assert_nil(defined?(super))")
|
||||
end
|
||||
|
||||
def test_respond_to
|
||||
obj = "#{self.class.name}##{__method__}"
|
||||
class << obj
|
||||
def respond_to?(mid)
|
||||
true
|
||||
end
|
||||
end
|
||||
assert_warn(/deprecated method signature.*\n.*respond_to\? is defined here/) do
|
||||
Warning[:deprecated] = true
|
||||
defined?(obj.foo)
|
||||
end
|
||||
assert_warn('') do
|
||||
Warning[:deprecated] = false
|
||||
defined?(obj.foo)
|
||||
end
|
||||
end
|
||||
|
||||
class ExampleRespondToMissing
|
||||
attr_reader :called
|
||||
|
||||
|
|
|
@ -2503,7 +2503,8 @@ vm_respond_to(rb_execution_context_t *ec, VALUE klass, VALUE obj, ID id, int pri
|
|||
VALUE path = RARRAY_AREF(location, 0);
|
||||
VALUE line = RARRAY_AREF(location, 1);
|
||||
if (!NIL_P(path)) {
|
||||
rb_compile_warn(RSTRING_PTR(path), NUM2INT(line),
|
||||
rb_category_compile_warn(RB_WARN_CATEGORY_DEPRECATED,
|
||||
RSTRING_PTR(path), NUM2INT(line),
|
||||
"respond_to? is defined here");
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче