summaryrefslogtreecommitdiff
path: root/proc.c
diff options
context:
space:
mode:
authorMike Dalessio <mike@37signals.com>2026-02-09 13:45:34 -0500
committerNobuyoshi Nakada <nobu.nakada@gmail.com>2026-02-10 08:26:48 +0900
commit836c1700104c305fa13cbc7b17d114705dd807b2 (patch)
treeb53b9c439f9c17a0d97c59d5cde131c4a8f8b67b /proc.c
parente0b757f63aa6e720af6200171b2f0841d4efe7ed (diff)
Fix UnboundMethod#== for methods from included/extended modules
Method#unbind clones the method entry, preserving its defined_class. For methods mixed in via include/extend, defined_class is an ICLASS, causing UnboundMethod#== to return false when comparing against the same method obtained via Module#instance_method. Resolve ICLASS defined_class in method_eq. Fixes [Bug #21873]
Diffstat (limited to 'proc.c')
-rw-r--r--proc.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/proc.c b/proc.c
index f0cdcae7b1..67963a1b01 100644
--- a/proc.c
+++ b/proc.c
@@ -2006,6 +2006,8 @@ method_eq(VALUE method, VALUE other)
klass1 = method_entry_defined_class(m1->me);
klass2 = method_entry_defined_class(m2->me);
+ if (RB_TYPE_P(klass1, T_ICLASS)) klass1 = RBASIC_CLASS(klass1);
+ if (RB_TYPE_P(klass2, T_ICLASS)) klass2 = RBASIC_CLASS(klass2);
if (!rb_method_entry_eq(m1->me, m2->me) ||
klass1 != klass2 ||