Skip to content

Instantly share code, notes, and snippets.

@tenderlove
Created April 12, 2016 00:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tenderlove/3455cf23961ecf1e5213359a59e4c40e to your computer and use it in GitHub Desktop.
Save tenderlove/3455cf23961ecf1e5213359a59e4c40e to your computer and use it in GitHub Desktop.
diff --git a/class.c b/class.c
index 0261838..65428be 100644
--- a/class.c
+++ b/class.c
@@ -1591,7 +1591,9 @@ singleton_class_of(VALUE obj)
klass = RBASIC(obj)->klass;
if (!(FL_TEST(klass, FL_SINGLETON) &&
rb_ivar_get(klass, id_attached) == obj)) {
+ rb_serial_t serial = RCLASS_SERIAL(klass);
klass = rb_make_metaclass(obj, klass);
+ RCLASS_SERIAL(klass) = serial;
}
if (OBJ_TAINTED(obj)) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment