mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[Bug #17780] Fix Method#super_method for module alias
Method#super_method crashes for aliased module methods because they are
not defined on a class. This bug was introduced in
c60aaed185
as part of bug #17130.
This commit is contained in:
parent
587e680008
commit
d8a13e5049
Notes:
git
2021-04-08 04:17:32 +09:00
2 changed files with 14 additions and 1 deletions
2
proc.c
2
proc.c
|
@ -3227,7 +3227,7 @@ method_super_method(VALUE method)
|
|||
TypedData_Get_Struct(method, struct METHOD, &method_data_type, data);
|
||||
iclass = data->iclass;
|
||||
if (!iclass) return Qnil;
|
||||
if (data->me->def->type == VM_METHOD_TYPE_ALIAS) {
|
||||
if (data->me->def->type == VM_METHOD_TYPE_ALIAS && data->me->defined_class) {
|
||||
super_class = RCLASS_SUPER(rb_find_defined_class_by_owner(data->me->defined_class,
|
||||
data->me->def->body.alias.original_me->owner));
|
||||
mid = data->me->def->body.alias.original_me->def->original_id;
|
||||
|
|
|
@ -1168,6 +1168,19 @@ class TestMethod < Test::Unit::TestCase
|
|||
assert_nil(m.super_method)
|
||||
end
|
||||
|
||||
# Bug 17780
|
||||
def test_super_method_module_alias
|
||||
m = Module.new do
|
||||
def foo
|
||||
end
|
||||
alias :f :foo
|
||||
end
|
||||
|
||||
method = m.instance_method(:f)
|
||||
super_method = method.super_method
|
||||
assert_nil(super_method)
|
||||
end
|
||||
|
||||
def rest_parameter(*rest)
|
||||
rest
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue