From: Dave Rolsky Date: Sun, 14 Sep 2008 21:09:14 +0000 (+0000) Subject: Don't destroy a metaclass that has an existing entry in the MOP cache X-Git-Tag: 0.66~3^2~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ab2b1e0145cb7020c1afc05cd493ee2881b12ace;p=gitmo%2FClass-MOP.git Don't destroy a metaclass that has an existing entry in the MOP cache --- diff --git a/lib/Class/MOP/Class.pm b/lib/Class/MOP/Class.pm index 3908891..afa8212 100644 --- a/lib/Class/MOP/Class.pm +++ b/lib/Class/MOP/Class.pm @@ -222,6 +222,13 @@ sub check_metaclass_compatability { no warnings 'uninitialized'; return unless $self->name =~ /^$ANON_CLASS_PREFIX/; + # Moose does a weird thing where it replaces the metaclass for + # class when fixing metaclass incompatibility. In that case, + # we don't want to clean out the namespace now. We can detect + # that because Moose will explicitly update the singleton + # cache in Class::MOP. + return if Class::MOP::does_metaclass_exist($self->name); + my ($serial_id) = ($self->name =~ /^$ANON_CLASS_PREFIX(\d+)/); no strict 'refs'; foreach my $key (keys %{$ANON_CLASS_PREFIX . $serial_id}) {