summaryrefslogtreecommitdiff
path: root/proc.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-08-07 08:07:58 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-08-07 08:07:58 (GMT)
commit6b7c4dfa6776083517564850032609618acbb710 (patch)
tree20554aa62bfc1e53df15ed174e3696663b472e60 /proc.c
parent95c84eac49064986bfd877ccf4d7e91e9929e833 (diff)
proc.c: fix for uncallable method
* proc.c (method_super_method): uncallable method entry does not have the defined class, use the owner instead. [ruby-core:70254] [Bug #11419] * test/ruby/test_method.rb (test_super_method_unbound): add test by Akira Matsuda. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51501 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'proc.c')
-rw-r--r--proc.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/proc.c b/proc.c
index 4b67c69..0d8ae11 100644
--- a/proc.c
+++ b/proc.c
@@ -1249,6 +1249,12 @@ mnew(VALUE klass, VALUE obj, ID id, VALUE mclass, int scope)
return mnew_from_me(me, klass, obj, id, mclass, scope);
}
+static inline VALUE
+method_entry_defined_class(const rb_method_entry_t *me)
+{
+ VALUE defined_class = me->defined_class;
+ return defined_class ? defined_class : me->owner;
+}
/**********************************************************************
*
@@ -1299,8 +1305,8 @@ method_eq(VALUE method, VALUE other)
m1 = (struct METHOD *)DATA_PTR(method);
m2 = (struct METHOD *)DATA_PTR(other);
- klass1 = m1->me->defined_class ? m1->me->defined_class : m1->me->owner;
- klass2 = m2->me->defined_class ? m2->me->defined_class : m2->me->owner;
+ klass1 = method_entry_defined_class(m1->me);
+ klass2 = method_entry_defined_class(m2->me);
if (!rb_method_entry_eq(m1->me, m2->me) ||
klass1 != klass2 ||
@@ -2326,7 +2332,7 @@ method_inspect(VALUE method)
defined_class = data->me->def->body.alias.original_me->owner;
}
else {
- defined_class = data->me->defined_class ? data->me->defined_class : data->me->owner;
+ defined_class = method_entry_defined_class(data->me);
}
if (RB_TYPE_P(defined_class, T_ICLASS)) {
@@ -2451,7 +2457,7 @@ method_super_method(VALUE method)
const rb_method_entry_t *me;
TypedData_Get_Struct(method, struct METHOD, &method_data_type, data);
- super_class = RCLASS_SUPER(data->me->defined_class);
+ super_class = RCLASS_SUPER(method_entry_defined_class(data->me));
if (!super_class) return Qnil;
me = (rb_method_entry_t *)rb_callable_method_entry_without_refinements(super_class, data->me->called_id);
if (!me) return Qnil;