diff options
-rw-r--r-- | class.c | 2 | ||||
-rw-r--r-- | include/ruby/ruby.h | 5 | ||||
-rw-r--r-- | test/ruby/test_class.rb | 3 |
3 files changed, 7 insertions, 3 deletions
@@ -1575,7 +1575,7 @@ singleton_class_of(VALUE obj) else { FL_UNSET(klass, FL_TAINT); } - if (OBJ_FROZEN(obj)) OBJ_FREEZE(klass); + if (OBJ_FROZEN(obj)) OBJ_FREEZE_RAW(klass); return klass; } diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h index b198e65625..4b57e7848b 100644 --- a/include/ruby/ruby.h +++ b/include/ruby/ruby.h @@ -1105,6 +1105,7 @@ struct RStruct { RBASIC(x)->flags |= RBASIC(s)->flags & FL_TAINT : 0) #define OBJ_FROZEN(x) (FL_ABLE(x) ? !!(RBASIC(x)->flags&FL_FREEZE) : 1) +#define OBJ_FREEZE_RAW(x) (RBASIC(x)->flags |= FL_FREEZE) #define OBJ_FREEZE(x) rb_obj_freeze_inline((VALUE)x) static inline void @@ -1112,9 +1113,9 @@ rb_obj_freeze_inline(VALUE x) { if (FL_ABLE(x)) { VALUE klass = RBASIC_CLASS(x); - RBASIC(x)->flags |= FL_FREEZE; + OBJ_FREEZE_RAW(x); if (FL_TEST(klass, (FL_SINGLETON|FL_FREEZE)) == FL_SINGLETON) { - RBASIC(klass)->flags |= FL_FREEZE; + OBJ_FREEZE_RAW(klass); } } } diff --git a/test/ruby/test_class.rb b/test/ruby/test_class.rb index 7259594f8e..293524b079 100644 --- a/test/ruby/test_class.rb +++ b/test/ruby/test_class.rb @@ -392,6 +392,9 @@ class TestClass < Test::Unit::TestCase assert_raise_with_message(RuntimeError, /frozen object/) { c.class_eval {def f; end} } + end + + def test_singleton_class_message c = Class.new.freeze assert_raise_with_message(RuntimeError, /frozen Class/) { def c.f; end |