From 18f605a29278d63207f10660fc2808438211f7d4 Mon Sep 17 00:00:00 2001 From: naruse Date: Wed, 25 Dec 2013 07:58:38 +0000 Subject: merge revision(s) 44380: [Backport #9296] * 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/branches/ruby_2_1@44410 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- proc.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'proc.c') diff --git a/proc.c b/proc.c index 638f22cb80..f8b2e3b3a9 100644 --- a/proc.c +++ b/proc.c @@ -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]); -- cgit v1.2.3