summaryrefslogtreecommitdiff
path: root/proc.c
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-05-27 16:03:12 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-05-27 16:03:12 +0000
commit69eab6991a64b6dff4209f96d719680a875b0d89 (patch)
tree118d9f1770ef9d22f0af8f4a1437c96580e15a2e /proc.c
parent41fd33e5fe22f13fd178c50adaee39ce53a3c155 (diff)
merge revision(s) r45179,r45564,r45565,r45584,r45585: [Backport #9721]
envutil.rb: move labeled_module and labeled_class * test/ruby/envutil.rb (labeled_module, labeled_class): move from test/ruby/test_module.rb. * proc.c (rb_method_call_with_block, umethod_bind): call with IClass including the module for a module instance method. [ruby-core:61936] [Bug #9721] * vm_insnhelper.c (vm_search_super_method): allow bound UnboundMethod case. * proc.c (umethod_bind): use the ancestor iclass instead of new iclass to get rid of infinite recursion, if the defined module is already included. [ruby-core:62014] [Bug #9721] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46190 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'proc.c')
-rw-r--r--proc.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/proc.c b/proc.c
index e3cecb7bbe..cc4e71080c 100644
--- a/proc.c
+++ b/proc.c
@@ -1826,6 +1826,7 @@ rb_method_call_with_block(int argc, VALUE *argv, VALUE method, VALUE pass_procva
if ((state = EXEC_TAG()) == 0) {
rb_thread_t *th = GET_THREAD();
rb_block_t *block = 0;
+ VALUE defined_class;
if (!NIL_P(pass_procval)) {
rb_proc_t *pass_proc;
@@ -1834,7 +1835,9 @@ rb_method_call_with_block(int argc, VALUE *argv, VALUE method, VALUE pass_procva
}
th->passed_block = block;
- result = rb_vm_call(th, data->recv, data->id, argc, argv, data->me, data->defined_class);
+ defined_class = data->defined_class;
+ if (BUILTIN_TYPE(defined_class) == T_MODULE) defined_class = data->rclass;
+ result = rb_vm_call(th, data->recv, data->id, argc, argv, data->me, defined_class);
}
POP_TAG();
if (safe >= 0)
@@ -1940,6 +1943,7 @@ umethod_bind(VALUE method, VALUE recv)
{
struct METHOD *data, *bound;
VALUE methclass;
+ VALUE rclass;
TypedData_Get_Struct(method, struct METHOD, &method_data_type, data);
@@ -1961,8 +1965,18 @@ umethod_bind(VALUE method, VALUE recv)
bound->me = ALLOC(rb_method_entry_t);
*bound->me = *data->me;
if (bound->me->def) bound->me->def->alias_count++;
+ rclass = CLASS_OF(recv);
+ if (BUILTIN_TYPE(bound->defined_class) == T_MODULE) {
+ 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 = CLASS_OF(recv);
+ bound->rclass = rclass;
data->ume = ALLOC(struct unlinked_method_entry_list_entry);
return method;