summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--eval.c4
-rw-r--r--test/ruby/test_class.rb9
-rw-r--r--vm_method.c4
4 files changed, 19 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 0994dc3..e1cafee 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Fri Sep 12 17:13:29 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * vm_method.c (rb_method_entry_make, remove_method): ditto.
+
Fri Sep 12 14:39:55 2014 SHIBATA Hiroshi <shibata.hiroshi@gmail.com>
* gems/bundled_gems: Upgraded to test-unit-3.0.1 and minitest-5.4.1
diff --git a/eval.c b/eval.c
index 90da225..cd91a1a 100644
--- a/eval.c
+++ b/eval.c
@@ -409,6 +409,10 @@ rb_frozen_class_p(VALUE klass)
noclass:
Check_Type(klass, T_CLASS);
}
+ if (FL_TEST(klass, FL_SINGLETON)) {
+ VALUE obj = rb_ivar_get(klass, id__attached__);
+ if (OBJ_FROZEN(obj)) OBJ_FREEZE(klass);
+ }
if (OBJ_FROZEN(klass)) {
const char *desc;
diff --git a/test/ruby/test_class.rb b/test/ruby/test_class.rb
index 963c497..9a4cdb0 100644
--- a/test/ruby/test_class.rb
+++ b/test/ruby/test_class.rb
@@ -384,4 +384,13 @@ class TestClass < Test::Unit::TestCase
Class.new.freeze.clone.to_s
}
end
+
+ def test_singleton_class_of_frozen_object
+ obj = Object.new
+ c = obj.singleton_class
+ obj.freeze
+ assert_raise(RuntimeError, /frozen object/) {
+ c.class_eval {def f; end}
+ }
+ end
end
diff --git a/vm_method.c b/vm_method.c
index 74dafab..60b7dc0 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -271,7 +271,7 @@ rb_method_entry_make(VALUE klass, ID mid, rb_method_type_t type,
}
}
- rb_check_frozen(klass);
+ rb_frozen_class_p(klass);
#if NOEX_NOREDEF
rklass = klass;
#endif
@@ -746,7 +746,7 @@ remove_method(VALUE klass, ID mid)
VALUE self = klass;
klass = RCLASS_ORIGIN(klass);
- rb_check_frozen(klass);
+ rb_frozen_class_p(klass);
if (mid == object_id || mid == id__send__ || mid == idInitialize) {
rb_warn("removing `%s' may cause serious problems", rb_id2name(mid));
}