Skip to content

Commit b208f1e

Browse files
committed
merge revision(s) 44527,44552,44553:
* vm_insnhelper.c (vm_search_super_method): when super called in a bound UnboundMethod generated from a module, no superclass is found since the current defined class is the module, then call method_missing in that case. [ruby-core:59619] [Bug ruby#9377] * vm_insnhelper.c (vm_search_super_method): allow bound method from a module, yet another method transplanting. git-svn-id: svn+ssh://svn.ruby-lang.org/ruby/branches/ruby_2_1@44843 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 61faac8 commit b208f1e

4 files changed

Lines changed: 34 additions & 2 deletions

File tree

ChangeLog

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
Wed Feb 5 22:28:41 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
2+
3+
* vm_insnhelper.c (vm_search_super_method): allow bound method from a
4+
module, yet another method transplanting.
5+
6+
Wed Feb 5 22:28:41 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
7+
8+
* vm_insnhelper.c (vm_search_super_method): when super called in a
9+
bound UnboundMethod generated from a module, no superclass is
10+
found since the current defined class is the module, then call
11+
method_missing in that case. [ruby-core:59619] [Bug #9377]
12+
113
Wed Feb 5 21:57:40 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
214

315
* ext/socket/socket.c (rsock_syserr_fail_host_port): add errno

test/ruby/test_super.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,4 +440,17 @@ def foo
440440
assert_equal(:ok, o.method(:foo).call, bug9315)
441441
end
442442
end
443+
444+
def test_missing_super_in_module_unbound_method
445+
bug9377 = '[ruby-core:59619] [Bug #9377]'
446+
447+
a = Module.new do
448+
def foo; super end
449+
end
450+
451+
m = a.instance_method(:foo).bind(Object.new)
452+
assert_raise(NoMethodError, bug9377) do
453+
m.call
454+
end
455+
end
443456
end

version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#define RUBY_VERSION "2.1.1"
22
#define RUBY_RELEASE_DATE "2014-02-05"
3-
#define RUBY_PATCHLEVEL 20
3+
#define RUBY_PATCHLEVEL 21
44

55
#define RUBY_RELEASE_YEAR 2014
66
#define RUBY_RELEASE_MONTH 2

vm_insnhelper.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2004,7 +2004,8 @@ vm_search_super_method(rb_thread_t *th, rb_control_frame_t *reg_cfp, rb_call_inf
20042004
current_defined_class = RCLASS_REFINED_CLASS(current_defined_class);
20052005
}
20062006

2007-
if (!FL_TEST(current_defined_class, RMODULE_INCLUDED_INTO_REFINEMENT) &&
2007+
if (BUILTIN_TYPE(current_defined_class) != T_MODULE &&
2008+
!FL_TEST(current_defined_class, RMODULE_INCLUDED_INTO_REFINEMENT) &&
20082009
!rb_obj_is_kind_of(ci->recv, current_defined_class)) {
20092010
VALUE m = RB_TYPE_P(current_defined_class, T_ICLASS) ?
20102011
RBASIC(current_defined_class)->klass : current_defined_class;
@@ -2024,6 +2025,12 @@ vm_search_super_method(rb_thread_t *th, rb_control_frame_t *reg_cfp, rb_call_inf
20242025
" by define_method() is not supported."
20252026
" Specify all arguments explicitly.");
20262027
}
2028+
if (!ci->klass) {
2029+
/* bound instance method of module */
2030+
ci->aux.missing_reason = NOEX_SUPER;
2031+
CI_SET_FASTPATH(ci, vm_call_method_missing, 1);
2032+
return;
2033+
}
20272034

20282035
/* TODO: use inline cache */
20292036
ci->me = rb_method_entry(ci->klass, ci->mid, &ci->defined_class);

0 commit comments

Comments
 (0)