use Try::Tiny;
use List::MoreUtils 'all';
-our $AUTHORITY = 'cpan:STEVAN';
-
use base 'Class::MOP::Module',
'Class::MOP::Mixin::HasAttributes',
'Class::MOP::Mixin::HasMethods';
return if in_global_destruction(); # it'll happen soon anyway and this just makes things more complicated
- no warnings 'uninitialized';
+ $self->free_anon_class
+ if $self->is_anon_class;
+ }
+
+ sub free_anon_class {
+ my $self = shift;
my $name = $self->name;
- return unless $name =~ /^$ANON_CLASS_PREFIX/o;
# Moose does a weird thing where it replaces the metaclass for
# class when fixing metaclass incompatibility. In that case,
my $current_meta = Class::MOP::get_metaclass_by_name($name);
return if $current_meta ne $self;
- my ($serial_id) = ($name =~ /^$ANON_CLASS_PREFIX(\d+)/o);
+ my ($first_fragments, $last_fragment) = ($name =~ /^(.*)::(.*)$/);
+
no strict 'refs';
@{$name . '::ISA'} = ();
%{$name . '::'} = ();
- delete ${$ANON_CLASS_PREFIX}{$serial_id . '::'};
+ delete ${$first_fragments}{$last_fragment . '::'};
Class::MOP::remove_metaclass_by_name($name);
}