summaryrefslogtreecommitdiff
path: root/vm_method.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-03-12 06:54:43 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-03-12 06:54:43 +0000
commitae36cf62b7ab864fe7dd8bc97ab7faecb4ca1670 (patch)
tree7a52041aedba6f6f284bc42535dabb1757303ff8 /vm_method.c
parentf2b094a522717be65a65f478159e6a3166b8651c (diff)
downloadruby-ae36cf62b7ab864fe7dd8bc97ab7faecb4ca1670.tar.gz
Fix setting method visibility on method wrapped with prepend
Ignore prepended modules when looking for already defined methods on a class to set the visibility on. [Fix GH-1834] From: Dylan Thacker-Smith <Dylan.Smith@shopify.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62725 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_method.c')
-rw-r--r--vm_method.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/vm_method.c b/vm_method.c
index c4fc9a9e28..f76d176d2c 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -1054,8 +1054,9 @@ rb_export_method(VALUE klass, ID name, rb_method_visibility_t visi)
{
rb_method_entry_t *me;
VALUE defined_class;
+ VALUE origin_class = RCLASS_ORIGIN(klass);
- me = search_method(klass, name, &defined_class);
+ me = search_method(origin_class, name, &defined_class);
if (!me && RB_TYPE_P(klass, T_MODULE)) {
me = search_method(rb_cObject, name, &defined_class);
}
@@ -1068,7 +1069,7 @@ rb_export_method(VALUE klass, ID name, rb_method_visibility_t visi)
if (METHOD_ENTRY_VISI(me) != visi) {
rb_vm_check_redefinition_opt_method(me, klass);
- if (klass == defined_class || RCLASS_ORIGIN(klass) == defined_class) {
+ if (klass == defined_class || origin_class == defined_class) {
METHOD_ENTRY_VISI_SET(me, visi);
if (me->def->type == VM_METHOD_TYPE_REFINED && me->def->body.refined.orig_me) {