summaryrefslogtreecommitdiff
path: root/class.c
diff options
context:
space:
mode:
Diffstat (limited to 'class.c')
-rw-r--r--class.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/class.c b/class.c
index 11210682fe..37ad4b542b 100644
--- a/class.c
+++ b/class.c
@@ -1539,7 +1539,8 @@ singleton_class_of(VALUE obj)
{
VALUE klass;
- if (FIXNUM_P(obj) || FLONUM_P(obj) || SYMBOL_P(obj)) {
+ if (FIXNUM_P(obj) || FLONUM_P(obj) || STATIC_SYM_P(obj)) {
+ no_singleton:
rb_raise(rb_eTypeError, "can't define singleton");
}
if (SPECIAL_CONST_P(obj)) {
@@ -1549,9 +1550,9 @@ singleton_class_of(VALUE obj)
return klass;
}
else {
- enum ruby_value_type type = BUILTIN_TYPE(obj);
- if (type == T_FLOAT || type == T_BIGNUM) {
- rb_raise(rb_eTypeError, "can't define singleton");
+ switch (BUILTIN_TYPE(obj)) {
+ case T_FLOAT: case T_BIGNUM: case T_SYMBOL:
+ goto no_singleton;
}
}