diff options
-rw-r--r-- | class.c | 3 | ||||
-rw-r--r-- | test/ruby/test_module.rb | 9 |
2 files changed, 10 insertions, 2 deletions
@@ -1054,8 +1054,7 @@ rb_include_module(VALUE klass, VALUE module) if (RB_TYPE_P(klass, T_MODULE)) { rb_subclass_entry_t *iclass = RCLASS_SUBCLASSES(klass); // skip the placeholder subclass entry at the head of the list - if (iclass && iclass->next) { - RUBY_ASSERT(!iclass->klass); + if (iclass && !iclass->klass) { iclass = iclass->next; } diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb index 0a6959c5e6..e744121718 100644 --- a/test/ruby/test_module.rb +++ b/test/ruby/test_module.rb @@ -475,6 +475,15 @@ class TestModule < Test::Unit::TestCase assert_not_include(mod.ancestor_list, BasicObject) end + def test_module_collected_extended_object + m1 = labeled_module("m1") + m2 = labeled_module("m2") + Object.new.extend(m1) + GC.start + m1.include(m2) + assert_equal([m1, m2], m1.ancestors) + end + def test_dup OtherSetup.call |