diff options
| author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-10-23 23:37:14 +0000 |
|---|---|---|
| committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-10-23 23:37:14 +0000 |
| commit | 4bb1f865fcfb5f6dda9fde30646e7a246f36361c (patch) | |
| tree | b9be1d6ebb2bc3bdea7d47796b6af13b84235801 | |
| parent | 9d919ae7bf4279b0ad25ff9622ff929849a3d3ba (diff) | |
| download | ruby-4bb1f865fcfb5f6dda9fde30646e7a246f36361c.tar.gz ruby-4bb1f865fcfb5f6dda9fde30646e7a246f36361c.tar.xz ruby-4bb1f865fcfb5f6dda9fde30646e7a246f36361c.zip | |
* class.c (rb_class_new): move class check to rb_check_inheritable().
* class.c (rb_check_inheritable): should not allow subclass of
class Class. [ruby-core:26225]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@25449 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
| -rw-r--r-- | ChangeLog | 7 | ||||
| -rw-r--r-- | class.c | 6 | ||||
| -rw-r--r-- | test/ruby/test_class.rb | 3 |
3 files changed, 11 insertions, 5 deletions
@@ -3,6 +3,13 @@ Sat Oct 24 00:36:47 2009 Tanaka Akira <akr@fsij.org> * io.c (io_cntl): update max file descriptor by the result of fcntl(F_DUPFD). +Fri Oct 23 16:31:14 2009 Yukihiro Matsumoto <matz@ruby-lang.org> + + * class.c (rb_class_new): move class check to rb_check_inheritable(). + + * class.c (rb_check_inheritable): should not allow subclass of + class Class. [ruby-core:26225] + Fri Oct 23 14:25:54 2009 Nobuyoshi Nakada <nobu@ruby-lang.org> * configure.in (target, target_alias): replace with real cpu. @@ -97,6 +97,9 @@ rb_check_inheritable(VALUE super) if (RBASIC(super)->flags & FL_SINGLETON) { rb_raise(rb_eTypeError, "can't make subclass of singleton class"); } + if (super == rb_cClass) { + rb_raise(rb_eTypeError, "can't make subclass of Class"); + } } @@ -111,9 +114,6 @@ rb_class_new(VALUE super) { Check_Type(super, T_CLASS); rb_check_inheritable(super); - if (super == rb_cClass) { - rb_raise(rb_eTypeError, "can't make subclass of Class"); - } return rb_class_boot(super); } diff --git a/test/ruby/test_class.rb b/test/ruby/test_class.rb index 8fe127231..a1f087ad6 100644 --- a/test/ruby/test_class.rb +++ b/test/ruby/test_class.rb @@ -170,8 +170,7 @@ class TestClass < Test::Unit::TestCase o = Object.new c = class << o; self; end assert_raise(TypeError) { Class.new(c) } - - assert_nothing_raised { Class.new(Class) } # is it OK? + assert_raise(TypeError) { Class.new(Class) } assert_raise(TypeError) { eval("class Foo < Class; end") } end |
