1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Supress class variable overtaken warning when original modules are the same

This issue was exposed by recent commits to better support including
refined modules.
This commit is contained in:
Jeremy Evans 2019-11-28 17:28:13 -08:00
parent 8a1f313e2e
commit 0c273b2279
Notes: git 2019-11-30 03:32:27 +09:00
2 changed files with 24 additions and 1 deletions

View file

@ -63,6 +63,29 @@ class TestVariable < Test::Unit::TestCase
assert_equal(1, o.singleton_class.class_variable_get(:@@foo))
end
class IncludeRefinedModuleClassVariableNoWarning
module Mod
@@_test_include_refined_module_class_variable = true
end
module Mod2
refine Mod do
end
end
include Mod
def t
@@_test_include_refined_module_class_variable
end
end
def test_include_refined_module_class_variable
assert_warning('') do
IncludeRefinedModuleClassVariableNoWarning.new.t
end
end
def test_variable
assert_instance_of(Integer, $$)

View file

@ -3025,7 +3025,7 @@ cvar_overtaken(VALUE front, VALUE target, ID id)
if (front && target != front) {
st_data_t did = (st_data_t)id;
if (RTEST(ruby_verbose)) {
if (RTEST(ruby_verbose) && original_module(front) != original_module(target)) {
rb_warning("class variable % "PRIsVALUE" of %"PRIsVALUE" is overtaken by %"PRIsVALUE"",
ID2SYM(id), rb_class_name(original_module(front)),
rb_class_name(original_module(target)));