From 71c0de7f08e2091ee19e0d759de73b522fe81369 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Thu, 6 Feb 2025 23:59:11 +0900 Subject: [PATCH] class.c (mrb_define_method_raw): take visibility from the class If not explicitly specified in the method struct. --- src/class.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/class.c b/src/class.c index e57af106e..9344eb539 100644 --- a/src/class.c +++ b/src/class.c @@ -779,7 +779,10 @@ mrb_define_method_raw(mrb_state *mrb, struct RClass *c, mrb_sym mid, mrb_method_ else { ptr.func = MRB_METHOD_FUNC(m); } - mt_put(mrb, h, mid, (MT_KEY_FLG(m.flags)&0xC)|MRB_VISIBILITY(c), ptr); + + int flags = MT_KEY_FLG(m.flags); + if ((flags & 0x3) == 0) flags |= MRB_VISIBILITY(c); + mt_put(mrb, h, mid, flags, ptr); mc_clear_by_id(mrb, mid); }