From 5cb5692ac8758420ddb7b5bdae337f2338d91b26 Mon Sep 17 00:00:00 2001 From: nobu Date: Sun, 15 May 2016 01:57:28 +0000 Subject: vm_insnhelper.c: deprecated constant in class * vm_insnhelper.c (vm_get_ev_const): warn deprecated constant even in the class context. [ruby-core:75505] [Bug #12382] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55005 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- variable.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'variable.c') diff --git a/variable.c b/variable.c index 9c3ce2d182..db26268cfa 100644 --- a/variable.c +++ b/variable.c @@ -2221,6 +2221,20 @@ rb_autoload_p(VALUE mod, ID id) return (ele = check_autoload_data(load)) ? ele->feature : Qnil; } +void +rb_const_warn_if_deprecated(const rb_const_entry_t *ce, VALUE klass, ID id) +{ + if (RB_CONST_DEPRECATED_P(ce)) { + if (klass == rb_cObject) { + rb_warn("constant ::%"PRIsVALUE" is deprecated", QUOTE_ID(id)); + } + else { + rb_warn("constant %"PRIsVALUE"::%"PRIsVALUE" is deprecated", + rb_class_name(klass), QUOTE_ID(id)); + } + } +} + static VALUE rb_const_get_0(VALUE klass, ID id, int exclude, int recurse, int visibility) { @@ -2238,15 +2252,7 @@ rb_const_get_0(VALUE klass, ID id, int exclude, int recurse, int visibility) rb_name_err_raise("private constant %2$s::%1$s referenced", klass, ID2SYM(id)); } - if (RB_CONST_DEPRECATED_P(ce)) { - if (klass == rb_cObject) { - rb_warn("constant ::%"PRIsVALUE" is deprecated", QUOTE_ID(id)); - } - else { - rb_warn("constant %"PRIsVALUE"::%"PRIsVALUE" is deprecated", - rb_class_name(klass), QUOTE_ID(id)); - } - } + rb_const_warn_if_deprecated(ce, klass, id); value = ce->value; if (value == Qundef) { if (am == tmp) break; -- cgit v1.2.3