aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--proc.c14
-rw-r--r--test/ruby/test_method.rb5
3 files changed, 24 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index bf7f3be52b..ea7187d450 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Fri Aug 7 17:07:56 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * 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.
+
Thu Aug 6 10:49:57 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
* node.c (rb_alloc_tmp_buffer): round up the size and check the
diff --git a/proc.c b/proc.c
index 4b67c69755..0d8ae11f09 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;
diff --git a/test/ruby/test_method.rb b/test/ruby/test_method.rb
index b7b140d9a0..da893b0646 100644
--- a/test/ruby/test_method.rb
+++ b/test/ruby/test_method.rb
@@ -868,6 +868,11 @@ class TestMethod < Test::Unit::TestCase
assert_equal(Base.instance_method(:foo), m, Feature9781)
m = assert_nothing_raised(NameError, Feature9781) {break m.super_method}
assert_nil(m, Feature9781)
+
+ bug11419 = '[ruby-core:70254]'
+ m = Object.instance_method(:tap)
+ m = assert_nothing_raised(NameError, bug11419) {break m.super_method}
+ assert_nil(m, bug11419)
end
def test_super_method_module