[前][次][番号順一覧][スレッド一覧]

ruby-changes:32376

From: nobu <ko1@a...>
Date: Sun, 29 Dec 2013 08:21:21 +0900 (JST)
Subject: [ruby-changes:32376] nobu:r44455 (trunk): vm_insnhelper.c: missing super in method module

nobu	2013-12-29 08:21:14 +0900 (Sun, 29 Dec 2013)

  New Revision: 44455

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=44455

  Log:
    vm_insnhelper.c: missing super in method module
    
    * 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]

  Modified files:
    trunk/ChangeLog
    trunk/test/ruby/test_super.rb
    trunk/vm_insnhelper.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 44454)
+++ ChangeLog	(revision 44455)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sun Dec 29 08:21:09 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* 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]
+
 Sun Dec 29 07:27:51 2013  Benoit Daloze  <eregontp@g...>
 
 	* compar.c (cmp_eq_recursive): Fix the return value, the value for
Index: vm_insnhelper.c
===================================================================
--- vm_insnhelper.c	(revision 44454)
+++ vm_insnhelper.c	(revision 44455)
@@ -2024,6 +2024,11 @@ vm_search_super_method(rb_thread_t *th, https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L2024
 		 " by define_method() is not supported."
 		 " Specify all arguments explicitly.");
     }
+    if (!ci->klass) {
+	ci->aux.missing_reason = NOEX_SUPER;
+	CI_SET_FASTPATH(ci, vm_call_method_missing, 1);
+	return;
+    }
 
     /* TODO: use inline cache */
     ci->me = rb_method_entry(ci->klass, ci->mid, &ci->defined_class);
Index: test/ruby/test_super.rb
===================================================================
--- test/ruby/test_super.rb	(revision 44454)
+++ test/ruby/test_super.rb	(revision 44455)
@@ -407,4 +407,19 @@ class TestSuper < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_super.rb#L407
     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
 end

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]