summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcharliesome <charliesome@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-08 10:48:33 +0000
committercharliesome <charliesome@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-08 10:48:33 +0000
commitb512e61ca02ad5ebdfb08581e87bbc0791009684 (patch)
tree66197e5c4809e02a4111a3046efb29946f8d6593
parent6c5000b5f1a00bb1d21215aeb1881e8c66d4676d (diff)
* class.c (include_modules_at): invalidate method cache if included
module contains constants * test/ruby/test_module.rb: add test git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41175 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--class.c2
-rw-r--r--test/ruby/test_module.rb20
3 files changed, 29 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 27ce3288da..616887e9a6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Sat Jun 8 19:47:00 2013 Charlie Somerville <charliesome@ruby-lang.org>
+
+ * class.c (include_modules_at): invalidate method cache if included
+ module contains constants
+
+ * test/ruby/test_module.rb: add test
+
Sat Jun 8 19:31:00 2013 Charlie Somerville <charliesome@ruby-lang.org>
* random.c (limited_big_rand): declare rnd, lim and mask as uint32_t
diff --git a/class.c b/class.c
index eeca4102af..e9b53dfafa 100644
--- a/class.c
+++ b/class.c
@@ -760,6 +760,8 @@ include_modules_at(const VALUE klass, VALUE c, VALUE module)
}
if (RMODULE_M_TBL(module) && RMODULE_M_TBL(module)->num_entries)
changed = 1;
+ if (RMODULE_CONST_TBL(module) && RMODULE_CONST_TBL(module)->num_entries)
+ changed = 1;
skip:
module = RCLASS_SUPER(module);
}
diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb
index fa7a408ede..816e5dc1ff 100644
--- a/test/ruby/test_module.rb
+++ b/test/ruby/test_module.rb
@@ -1759,6 +1759,26 @@ class TestModule < Test::Unit::TestCase
assert_raise(NoMethodError, bug8284) {Object.define_method}
end
+ def test_include_module_with_constants_invalidates_method_cache
+ assert_in_out_err([], <<-RUBY, %w(123 456), [])
+ A = 123
+
+ class Foo
+ def self.a
+ A
+ end
+ end
+
+ module M
+ A = 456
+ end
+
+ puts Foo.a
+ Foo.send(:include, M)
+ puts Foo.a
+ RUBY
+ end
+
private
def assert_top_method_is_private(method)