diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-12-24 07:28:11 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-12-24 07:28:11 +0000 |
commit | 1fc33199736f316dd71d0c551edbf514528ddde6 (patch) | |
tree | 41f04b811f87b4439d37b2cd365fda59147ed5ac /proc.c | |
parent | 3c0cbea874a38ee233cae86e1dd854f00d5d6b00 (diff) | |
download | ruby-1fc33199736f316dd71d0c551edbf514528ddde6.tar.gz |
proc.c: make method by define_method public
* proc.c (rb_mod_define_method): consider visibility only if self
in the caller is same as the receiver, otherwise make public as
well as old behavior. [ruby-core:57747] [Bug #9005]
[ruby-core:58497] [Bug #9141]
* vm.c (rb_vm_cref_in_context): return ruby level cref if self is
same.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44380 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'proc.c')
-rw-r--r-- | proc.c | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -14,6 +14,8 @@ #include "gc.h" #include "iseq.h" +NODE *rb_vm_cref_in_context(VALUE self); + struct METHOD { VALUE recv; VALUE rclass; @@ -1619,7 +1621,12 @@ rb_mod_define_method(int argc, VALUE *argv, VALUE mod) { ID id; VALUE body; - int noex = (int)rb_vm_cref()->nd_visi; + int noex = NOEX_PUBLIC; + const NODE *cref = rb_vm_cref_in_context(mod); + + if (cref && cref->nd_clss == mod) { + noex = (int)cref->nd_visi; + } if (argc == 1) { id = rb_to_id(argv[0]); |