* 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] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38761 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
a5ddc2e196
commit
4707fdea01
@ -1,3 +1,9 @@
|
|||||||
|
Thu Jan 10 16:31:20 2013 Shugo Maeda <shugo@ruby-lang.org>
|
||||||
|
|
||||||
|
* 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@ruby-lang.org>
|
Thu Jan 10 16:47:18 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* ext/tk/extconf.rb (find_tcltk_header): use have_header instead of
|
* ext/tk/extconf.rb (find_tcltk_header): use have_header instead of
|
||||||
|
@ -265,7 +265,7 @@ class TestSuper < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
}
|
}
|
||||||
obj = sub_class.new
|
obj = sub_class.new
|
||||||
assert_raise(NotImplementedError) do
|
assert_raise(TypeError) do
|
||||||
obj.foo
|
obj.foo
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -285,7 +285,7 @@ class TestSuper < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
}
|
}
|
||||||
obj = sub_class.new
|
obj = sub_class.new
|
||||||
assert_raise(NotImplementedError) do
|
assert_raise(TypeError) do
|
||||||
obj.foo
|
obj.foo
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -321,7 +321,7 @@ class TestSuper < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
}
|
}
|
||||||
obj = sub_class.new
|
obj = sub_class.new
|
||||||
assert_raise(NotImplementedError) do
|
assert_raise(TypeError) do
|
||||||
obj.foo.call
|
obj.foo.call
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1943,7 +1943,13 @@ vm_search_super_method(rb_thread_t *th, rb_control_frame_t *reg_cfp, rb_call_inf
|
|||||||
|
|
||||||
if (!FL_TEST(current_defined_class, RMODULE_INCLUDED_INTO_REFINEMENT) &&
|
if (!FL_TEST(current_defined_class, RMODULE_INCLUDED_INTO_REFINEMENT) &&
|
||||||
!rb_obj_is_kind_of(ci->recv, current_defined_class)) {
|
!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);
|
vm_search_superclass(GET_CFP(), iseq, sigval, ci);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user