summaryrefslogtreecommitdiff
path: root/proc.c
diff options
context:
space:
mode:
Diffstat (limited to 'proc.c')
-rw-r--r--proc.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/proc.c b/proc.c
index 1271a3b..8153cc9 100644
--- a/proc.c
+++ b/proc.c
@@ -2044,7 +2044,13 @@ umethod_bind(VALUE method, VALUE recv)
if (bound->me->def) bound->me->def->alias_count++;
rclass = CLASS_OF(recv);
if (BUILTIN_TYPE(bound->defined_class) == T_MODULE) {
- rclass = rb_include_class_new(methclass, rclass);
+ VALUE ic = rb_class_search_ancestor(rclass, bound->defined_class);
+ if (ic) {
+ rclass = ic;
+ }
+ else {
+ rclass = rb_include_class_new(methclass, rclass);
+ }
}
bound->recv = recv;
bound->rclass = rclass;