From: Dave Rolsky Date: Sun, 14 Sep 2008 21:11:32 +0000 (+0000) Subject: Weaken anon class metaclasses after updating them in the CMOP cache. X-Git-Tag: 0.58~34^2~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4c5fcc12f6173510239c1d4b120df9feb176c2f5;p=gitmo%2FMoose.git Weaken anon class metaclasses after updating them in the CMOP cache. --- diff --git a/lib/Moose/Meta/Class.pm b/lib/Moose/Meta/Class.pm index 31261a3..382c6b0 100644 --- a/lib/Moose/Meta/Class.pm +++ b/lib/Moose/Meta/Class.pm @@ -394,12 +394,11 @@ sub _reinitialize_with { bless $self, ref $new_self; - # FIXME? This seems to be necessary in some cases because of how - # Class::MOP::Class->construct_class_instance will weaken the - # metaclass store entry for an anonymous class. However, if that - # anonymous class is a metaclass's metaclass, we don't want it - # going out of scope. I'm not sure this is the right fix at all. + # We need to replace the cached metaclass instance or else when it + # goes out of scope Class::MOP::Class destroy's the namespace for + # the metaclass's class, causing much havoc. Class::MOP::store_metaclass_by_name( $self->name, $self ); + Class::MOP::weaken_metaclass( $self->name ) if $self->is_anon_class; } # In the more complex case, we share a common ancestor with our