summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--test/ruby/test_module.rb7
-rw-r--r--version.h2
-rw-r--r--vm_method.c4
4 files changed, 16 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 63b10e0cb2..100f7f31ec 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Tue Apr 23 23:06:43 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * vm_method.c (rb_mod_public_method): fix visibility on anonymous
+ module. set visibility of singleton method, not method in base
+ class. [ruby-core:54404] [Bug #8284]
+
Tue Apr 23 22:33:16 2013 Shugo Maeda <shugo@ruby-lang.org>
* lib/net/imap.rb (getacl_response): parse the mailbox of an ACL
diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb
index 1e0f154bd2..06c1820853 100644
--- a/test/ruby/test_module.rb
+++ b/test/ruby/test_module.rb
@@ -1675,6 +1675,13 @@ class TestModule < Test::Unit::TestCase
end
end
+ def test_anonymous_module_public_class_method
+ bug8284 = '[ruby-core:54404] [Bug #8284]'
+ assert_raise(NoMethodError) {Object.define_method}
+ Module.new.public_class_method(:define_method)
+ assert_raise(NoMethodError, bug8284) {Object.define_method}
+ end
+
private
def assert_top_method_is_private(method)
diff --git a/version.h b/version.h
index f7aa078cf8..b89145432d 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.0.0"
#define RUBY_RELEASE_DATE "2013-04-23"
-#define RUBY_PATCHLEVEL 162
+#define RUBY_PATCHLEVEL 163
#define RUBY_RELEASE_YEAR 2013
#define RUBY_RELEASE_MONTH 4
diff --git a/vm_method.c b/vm_method.c
index 951ee4e6a8..e00c282ca9 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -1359,7 +1359,7 @@ rb_mod_private(int argc, VALUE *argv, VALUE module)
static VALUE
rb_mod_public_method(int argc, VALUE *argv, VALUE obj)
{
- set_method_visibility(CLASS_OF(obj), argc, argv, NOEX_PUBLIC);
+ set_method_visibility(rb_singleton_class(obj), argc, argv, NOEX_PUBLIC);
return obj;
}
@@ -1382,7 +1382,7 @@ rb_mod_public_method(int argc, VALUE *argv, VALUE obj)
static VALUE
rb_mod_private_method(int argc, VALUE *argv, VALUE obj)
{
- set_method_visibility(CLASS_OF(obj), argc, argv, NOEX_PRIVATE);
+ set_method_visibility(rb_singleton_class(obj), argc, argv, NOEX_PRIVATE);
return obj;
}