summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-26 07:26:49 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-26 07:26:49 +0000
commita43b8412ea13b43cdd65177ed75ac76001ec8734 (patch)
tree096f161fb31aa64ecece1483ab65301c1078927d
parentfbc47099df8f311c7de999f7feb1279e57961c1e (diff)
merge revision(s) 41175: [Backport #8503]
* 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/branches/ruby_1_9_3@41645 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--class.c2
-rw-r--r--test/ruby/test_module.rb20
-rw-r--r--version.h2
4 files changed, 30 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 3ff95b5d40..5000f8787c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Wed Jun 26 16:22:12 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
+
Wed Jun 26 16:13:25 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* io.c (io_getc): fix 7bit coderange condition, check if ascii read
diff --git a/class.c b/class.c
index 4fbdf18fb7..02e682688c 100644
--- a/class.c
+++ b/class.c
@@ -699,6 +699,8 @@ rb_include_module(VALUE klass, VALUE module)
c = RCLASS_SUPER(c) = include_class_new(module, RCLASS_SUPER(c));
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 6176f484bc..6673852d9c 100644
--- a/test/ruby/test_module.rb
+++ b/test/ruby/test_module.rb
@@ -1220,4 +1220,24 @@ class TestModule < Test::Unit::TestCase
INPUT
assert_in_out_err([], src, ["NameError"], [])
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
end
diff --git a/version.h b/version.h
index 9bb30bb770..c3009164ba 100644
--- a/version.h
+++ b/version.h
@@ -1,5 +1,5 @@
#define RUBY_VERSION "1.9.3"
-#define RUBY_PATCHLEVEL 437
+#define RUBY_PATCHLEVEL 438
#define RUBY_RELEASE_DATE "2013-06-26"
#define RUBY_RELEASE_YEAR 2013