From 836c1700104c305fa13cbc7b17d114705dd807b2 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Mon, 9 Feb 2026 13:45:34 -0500 Subject: 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] --- proc.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'proc.c') 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 || -- cgit v1.2.3