diff options
author | NARUSE, Yui <[email protected]> | 2021-02-02 15:49:51 +0900 |
---|---|---|
committer | NARUSE, Yui <[email protected]> | 2021-02-02 15:49:51 +0900 |
commit | fb6cb226a03c2eeaf4fe68b282fcd6e4a8696ffd (patch) | |
tree | d6e098eeb6d2c3a4c11a7bd0107186d93bb8910d | |
parent | d370cb62d26f212e431d4a7b38db56254c95cd5d (diff) |
merge revision(s) 8dfae85adb96cf3da84bf38f2103969d4a7aed3f: [Backport #17575]
Warn the defined location as deprecation as well as the main message
[Bug #17575]
---
test/ruby/test_defined.rb | 17 +++++++++++++++++
vm_method.c | 3 ++-
2 files changed, 19 insertions(+), 1 deletion(-)
-rw-r--r-- | test/ruby/test_defined.rb | 17 | ||||
-rw-r--r-- | version.h | 2 | ||||
-rw-r--r-- | vm_method.c | 3 |
3 files changed, 20 insertions, 2 deletions
diff --git a/test/ruby/test_defined.rb b/test/ruby/test_defined.rb index b22db700da..73c192a0ae 100644 --- a/test/ruby/test_defined.rb +++ b/test/ruby/test_defined.rb @@ -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 @@ -12,7 +12,7 @@ # define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR #define RUBY_VERSION_TEENY 0 #define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR -#define RUBY_PATCHLEVEL 27 +#define RUBY_PATCHLEVEL 28 #define RUBY_RELEASE_YEAR 2021 #define RUBY_RELEASE_MONTH 2 diff --git a/vm_method.c b/vm_method.c index e545146df9..928b509651 100644 --- a/vm_method.c +++ b/vm_method.c @@ -2493,7 +2493,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"); } } |