summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-01-31 08:58:59 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-01-31 08:58:59 +0000
commit32e4d034ca81bffeb6415379eb91a4e90254c886 (patch)
tree1ed8dd47e10d06bd93c97206943e8bf3731adc0f
parentedacfadad6dc07801adcfedab4ca901775ecd909 (diff)
merge revision(s) 44455,44458,44510: [Backport #9349]
* vm_insnhelper.c (vm_search_super_method): direct superclass of a module is found when super called in a Method object generated a method defined in a module, call method_missing in that case. [ruby-core:59358] [Bug #9315] * proc.c (mnew_from_me): keep iclass as-is, to make inheritance chain consistent. [ruby-core:59358] [Bug #9315] * proc.c (method_owner): return the original defined_class from prepended iclass, instead. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@44777 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog8
-rw-r--r--proc.c13
-rw-r--r--test/ruby/test_super.rb33
-rw-r--r--version.h2
4 files changed, 50 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 2dafde5845..601436f326 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Fri Jan 31 12:10:16 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * proc.c (mnew_from_me): keep iclass as-is, to make inheritance
+ chain consistent. [ruby-core:59358] [Bug #9315]
+
+ * proc.c (method_owner): return the original defined_class from
+ prepended iclass, instead.
+
Fri Jan 31 12:05:59 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
* configure.in: let mingw do something black-magic, and check if
diff --git a/proc.c b/proc.c
index f8b2e3b3a9..e52beaf9d8 100644
--- a/proc.c
+++ b/proc.c
@@ -1171,10 +1171,6 @@ mnew_from_me(rb_method_entry_t *me, VALUE defined_class, VALUE klass,
goto again;
}
- if (RB_TYPE_P(defined_class, T_ICLASS)) {
- defined_class = RBASIC_CLASS(defined_class);
- }
-
klass = defined_class;
while (rclass != klass &&
@@ -1396,9 +1392,16 @@ static VALUE
method_owner(VALUE obj)
{
struct METHOD *data;
+ VALUE defined_class;
TypedData_Get_Struct(obj, struct METHOD, &method_data_type, data);
- return data->defined_class;
+ defined_class = data->defined_class;
+
+ if (RB_TYPE_P(defined_class, T_ICLASS)) {
+ defined_class = RBASIC_CLASS(defined_class);
+ }
+
+ return defined_class;
}
void
diff --git a/test/ruby/test_super.rb b/test/ruby/test_super.rb
index 846f40946d..c5f724ebb8 100644
--- a/test/ruby/test_super.rb
+++ b/test/ruby/test_super.rb
@@ -407,4 +407,37 @@ class TestSuper < Test::Unit::TestCase
assert_equal([false, false], y.foo(false, false))
assert_equal([1, 2, 3, false, 5], y.foo(1, 2, 3, false, 5))
end
+
+ def test_missing_super_in_method_module
+ bug9315 = '[ruby-core:59358] [Bug #9315]'
+ a = Module.new do
+ def foo
+ super
+ end
+ end
+ b = Class.new do
+ include a
+ end
+ assert_raise(NoMethodError, bug9315) do
+ b.new.method(:foo).call
+ end
+ end
+
+ def test_module_super_in_method_module
+ bug9315 = '[ruby-core:59589] [Bug #9315]'
+ a = Module.new do
+ def foo
+ super
+ end
+ end
+ c = Class.new do
+ def foo
+ :ok
+ end
+ end
+ o = c.new.extend(a)
+ assert_nothing_raised(NoMethodError, bug9315) do
+ assert_equal(:ok, o.method(:foo).call, bug9315)
+ end
+ end
end
diff --git a/version.h b/version.h
index 072bf28ce9..c361122024 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.1.1"
#define RUBY_RELEASE_DATE "2014-01-31"
-#define RUBY_PATCHLEVEL 12
+#define RUBY_PATCHLEVEL 13
#define RUBY_RELEASE_YEAR 2014
#define RUBY_RELEASE_MONTH 1