summaryrefslogtreecommitdiff
path: root/vm_method.c
diff options
context:
space:
mode:
authorAlan Wu <XrXr@users.noreply.github.com>2021-05-20 18:52:32 -0400
committerAlan Wu <XrXr@users.noreply.github.com>2021-05-21 12:12:31 -0400
commit636d4f7eb9f3fcb088e1a44af4181c4aa36789b4 (patch)
tree740452cda5e1c16efd05d7da2e31b924c5cb8922 /vm_method.c
parent50a534a1526e2b9f4ea41e44b802bd73f9cebbeb (diff)
downloadruby-636d4f7eb9f3fcb088e1a44af4181c4aa36789b4.tar.gz
Avoid setting the visibility of refinement method entries
Since refinement search is always performed, these entries should always be public. The method entry that the refinement search returns decides the visibility. Fixes [Bug #17822]
Diffstat (limited to 'vm_method.c')
-rw-r--r--vm_method.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/vm_method.c b/vm_method.c
index 34200dc5f8..740279cdc9 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -1409,11 +1409,16 @@ rb_export_method(VALUE klass, ID name, rb_method_visibility_t visi)
rb_vm_check_redefinition_opt_method(me, klass);
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) {
- METHOD_ENTRY_VISI_SET((rb_method_entry_t *)me->def->body.refined.orig_me, visi);
- }
+ if (me->def->type == VM_METHOD_TYPE_REFINED) {
+ // Refinement method entries should always be public because the refinement
+ // search is always performed.
+ if (me->def->body.refined.orig_me) {
+ METHOD_ENTRY_VISI_SET((rb_method_entry_t *)me->def->body.refined.orig_me, visi);
+ }
+ }
+ else {
+ METHOD_ENTRY_VISI_SET(me, visi);
+ }
rb_clear_method_cache(klass, name);
}
else {