From: Dave Rolsky Date: Tue, 30 Jun 2009 20:10:11 +0000 (-0500) Subject: Fixes to accomodate a metaclass which is an anon subclass of something X-Git-Tag: 0.89~10 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6c0bd97ea96792cd8fc9e5e03b56c2bc75df32ee;p=gitmo%2FClass-MOP.git Fixes to accomodate a metaclass which is an anon subclass of something like Moose::Meta::Class. This happens when you make your own metaclass using Moose and then load modules which apply roles to the metaclass. Also, when making the new metaclass immutable, don't inline the constructor. --- diff --git a/lib/Class/MOP/Class.pm b/lib/Class/MOP/Class.pm index 2a6f01c..9ba78e8 100644 --- a/lib/Class/MOP/Class.pm +++ b/lib/Class/MOP/Class.pm @@ -1098,7 +1098,16 @@ sub _immutable_metaclass { return $class_name if Class::MOP::is_class_loaded($class_name); - my $meta = (ref $self)->create( + # If the metaclass is a subclass of CMOP::Class which has had + # metaclass roles applied (via Moose), then we want to make sure + # that we preserve that anonymous class (see Fey::ORM for an + # example of where this matters). + my $meta_name + = $self->meta->is_immutable + ? $self->meta->get_mutable_metaclass_name + : ref $self->meta; + + my $meta = $meta_name->create( $class_name, superclasses => [ ref $self ], ); @@ -1115,7 +1124,7 @@ sub _immutable_metaclass { } } - $meta->make_immutable; + $meta->make_immutable( inline_constructor => 0 ); return $class_name; }