merge revision(s) 40346: [Backport #8284]

* 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]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@40427 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nagachika 2013-04-23 14:32:49 +00:00
parent 96de351eed
commit c967493b65
4 changed files with 16 additions and 3 deletions

View file

@ -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> 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 * lib/net/imap.rb (getacl_response): parse the mailbox of an ACL

View file

@ -1675,6 +1675,13 @@ class TestModule < Test::Unit::TestCase
end end
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 private
def assert_top_method_is_private(method) def assert_top_method_is_private(method)

View file

@ -1,6 +1,6 @@
#define RUBY_VERSION "2.0.0" #define RUBY_VERSION "2.0.0"
#define RUBY_RELEASE_DATE "2013-04-23" #define RUBY_RELEASE_DATE "2013-04-23"
#define RUBY_PATCHLEVEL 162 #define RUBY_PATCHLEVEL 163
#define RUBY_RELEASE_YEAR 2013 #define RUBY_RELEASE_YEAR 2013
#define RUBY_RELEASE_MONTH 4 #define RUBY_RELEASE_MONTH 4

View file

@ -1359,7 +1359,7 @@ rb_mod_private(int argc, VALUE *argv, VALUE module)
static VALUE static VALUE
rb_mod_public_method(int argc, VALUE *argv, VALUE obj) 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; return obj;
} }
@ -1382,7 +1382,7 @@ rb_mod_public_method(int argc, VALUE *argv, VALUE obj)
static VALUE static VALUE
rb_mod_private_method(int argc, VALUE *argv, VALUE obj) 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; return obj;
} }