diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-12-21 08:29:06 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-12-21 08:29:06 +0000 |
commit | 7c34e359a1d8e1affabeaa43377cf49f09933dfd (patch) | |
tree | 8a5568fbc4fe82c986a8c65f0cee8d5ae39c9817 /class.c | |
parent | 3e67076db01cbc53486e51f4b455220c9e4a3890 (diff) | |
download | ruby-7c34e359a1d8e1affabeaa43377cf49f09933dfd.tar.gz |
* class.c (rb_check_inheritable): new function. [ruby-dev:22316]
* intern.h: add prototype.
* eval.c (superclass): use rb_check_inheritable().
* object.c (rb_class_initialize): check argument validity.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5236 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'class.c')
-rw-r--r-- | class.c | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -178,6 +178,19 @@ rb_define_class_id(id, super) return klass; } +void +rb_check_inheritable(super) + VALUE super; +{ + if (TYPE(super) != T_CLASS) { + rb_raise(rb_eTypeError, "superclass must be a Class (%s given)", + rb_obj_classname(super)); + } + if (RBASIC(super)->flags & FL_SINGLETON) { + rb_raise(rb_eTypeError, "can't make subclass of virtual class"); + } +} + VALUE rb_class_inherited(super, klass) VALUE super, klass; |