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

ruby-changes:26710

From: shugo <ko1@a...>
Date: Thu, 10 Jan 2013 16:51:49 +0900 (JST)
Subject: [ruby-changes:26710] shugo:r38761 (trunk): * vm_insnhelper.c (vm_search_super_method): raise a TypeError

shugo	2013-01-10 16:51:35 +0900 (Thu, 10 Jan 2013)

  New Revision: 38761

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

  Log:
    * vm_insnhelper.c (vm_search_super_method): raise a TypeError
      instead of a NotImplementError if self is not an instance of the
      current class.  [ruby-dev:39772] [Bug #2402]

  Modified files:
    trunk/ChangeLog
    trunk/test/ruby/test_super.rb
    trunk/vm_insnhelper.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 38760)
+++ ChangeLog	(revision 38761)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Jan 10 16:31:20 2013  Shugo Maeda  <shugo@r...>
+
+	* vm_insnhelper.c (vm_search_super_method): raise a TypeError
+	  instead of a NotImplementError if self is not an instance of the
+	  current class.  [ruby-dev:39772] [Bug #2402]
+
 Thu Jan 10 16:47:18 2013  Nobuyoshi Nakada  <nobu@r...>
 
 	* ext/tk/extconf.rb (find_tcltk_header): use have_header instead of
Index: vm_insnhelper.c
===================================================================
--- vm_insnhelper.c	(revision 38760)
+++ vm_insnhelper.c	(revision 38761)
@@ -1943,7 +1943,13 @@ vm_search_super_method(rb_thread_t *th, https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1943
 
     if (!FL_TEST(current_defined_class, RMODULE_INCLUDED_INTO_REFINEMENT) &&
 	!rb_obj_is_kind_of(ci->recv, current_defined_class)) {
-	rb_raise(rb_eNotImpError, "super from singleton method that is defined to multiple classes is not supported; this will be fixed in 2.0.0 or later");
+	VALUE m = RB_TYPE_P(current_defined_class, T_ICLASS) ?
+	    RBASIC(current_defined_class)->klass : current_defined_class;
+
+	rb_raise(rb_eTypeError,
+		 "self has wrong type to call super in this context: "
+		 "%s (expected %s)",
+		 rb_obj_classname(ci->recv), rb_class2name(m));
     }
 
     vm_search_superclass(GET_CFP(), iseq, sigval, ci);
Index: test/ruby/test_super.rb
===================================================================
--- test/ruby/test_super.rb	(revision 38760)
+++ test/ruby/test_super.rb	(revision 38761)
@@ -265,7 +265,7 @@ class TestSuper < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_super.rb#L265
       end
     }
     obj = sub_class.new
-    assert_raise(NotImplementedError) do
+    assert_raise(TypeError) do
       obj.foo
     end
   end
@@ -285,7 +285,7 @@ class TestSuper < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_super.rb#L285
       end
     }
     obj = sub_class.new
-    assert_raise(NotImplementedError) do
+    assert_raise(TypeError) do
       obj.foo
     end
   end
@@ -321,7 +321,7 @@ class TestSuper < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_super.rb#L321
       end
     }
     obj = sub_class.new
-    assert_raise(NotImplementedError) do
+    assert_raise(TypeError) do
       obj.foo.call
     end
   end

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

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