summaryrefslogtreecommitdiff
path: root/class.c
diff options
context:
space:
mode:
Diffstat (limited to 'class.c')
-rw-r--r--class.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/class.c b/class.c
index 6f6c5d2b856..1c3391a5d47 100644
--- a/class.c
+++ b/class.c
@@ -19,7 +19,7 @@
extern st_table *rb_class_tbl;
VALUE
-rb_class_new(super)
+rb_class_boot(super)
VALUE super;
{
NEWOBJ(klass, struct RClass);
@@ -33,6 +33,20 @@ rb_class_new(super)
return (VALUE)klass;
}
+VALUE
+rb_class_new(super)
+ VALUE super;
+{
+ Check_Type(super, T_CLASS);
+ if (super == rb_cClass) {
+ rb_raise(rb_eTypeError, "can't make subclass of Class");
+ }
+ if (FL_TEST(super, FL_SINGLETON)) {
+ rb_raise(rb_eTypeError, "can't make subclass of virtual class");
+ }
+ return rb_class_boot(super);
+}
+
static int
clone_method(mid, body, tbl)
ID mid;
@@ -78,7 +92,7 @@ VALUE
rb_singleton_class_new(super)
VALUE super;
{
- VALUE klass = rb_class_new(super);
+ VALUE klass = rb_class_boot(super);
FL_SET(klass, FL_SINGLETON);
return klass;