From: Jesse Luehrs Date: Mon, 19 Apr 2010 01:50:45 +0000 (-0500) Subject: complain about unsafe fixing, since cmop doesn't anymore X-Git-Tag: 1.05~13 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=590e889408738c50836b457f2db3768e42a226f4;p=gitmo%2FMoose.git complain about unsafe fixing, since cmop doesn't anymore for this specific case, anyway --- diff --git a/lib/Moose/Meta/Class.pm b/lib/Moose/Meta/Class.pm index a02851a..107dc0f 100644 --- a/lib/Moose/Meta/Class.pm +++ b/lib/Moose/Meta/Class.pm @@ -6,7 +6,7 @@ use warnings; use Class::MOP; -use Carp (); +use Carp qw( confess ); use Data::OptList; use List::Util qw( first ); use List::MoreUtils qw( any all uniq first_index ); @@ -537,6 +537,10 @@ sub _fix_class_metaclass_incompatibility { $self->SUPER::_fix_class_metaclass_incompatibility(@_); if ($self->_can_fix_class_metaclass_incompatibility_by_role_reconciliation($super_meta)) { + ($self->is_pristine) + || confess "Can't fix metaclass incompatibility for " + . $self->name + . " because it is not pristine."; my $super_meta_name = $super_meta->is_immutable ? $super_meta->_get_mutable_metaclass_name : blessed($super_meta); @@ -561,6 +565,10 @@ sub _fix_single_metaclass_incompatibility { $self->SUPER::_fix_single_metaclass_incompatibility(@_); if ($self->_can_fix_single_metaclass_incompatibility_by_role_reconciliation($metaclass_type, $super_meta)) { + ($self->is_pristine) + || confess "Can't fix metaclass incompatibility for " + . $self->name + . " because it is not pristine."; my %metaclasses = $self->_base_metaclasses; my $class_specific_meta_subclass_meta = $self->_reconcile_roles_for_metaclass($self->$metaclass_type, $super_meta->$metaclass_type); my $new_self = $super_meta->reinitialize( diff --git a/t/050_metaclasses/052_metaclass_compat.t b/t/050_metaclasses/052_metaclass_compat.t index c2b8ab4..e6d9f45 100644 --- a/t/050_metaclasses/052_metaclass_compat.t +++ b/t/050_metaclasses/052_metaclass_compat.t @@ -241,4 +241,40 @@ ok(Foo::Sub->meta->constructor_class->meta->can('does_role') 'MI extends after_generated_methods with metaclass roles (reverse)'; } +{ + package Foo6::Meta::Role; + use Moose::Role; +} +{ + package Foo6::SuperClass::WithMetaRole; + use Moose -traits =>'Foo6::Meta::Role'; +} +{ + package Foo6::Meta::OtherRole; + use Moose::Role; +} +{ + package Foo6::SuperClass::After::Attribute; + use Moose -traits =>'Foo6::Meta::OtherRole'; +} +{ + package Foo6; + use Moose; + my @superclasses = ('Foo6::SuperClass::WithMetaRole'); + extends @superclasses; + + has an_attribute_generating_methods => ( is => 'ro' ); + + push(@superclasses, 'Foo6::SuperClass::After::Attribute'); + + ::throws_ok { + extends @superclasses; + } qr/compat.*pristine/, + 'unsafe MI extends after_generated_methods with metaclass roles'; + ::throws_ok { + extends reverse @superclasses; + } qr/compat.*pristine/, + 'unsafe MI extends after_generated_methods with metaclass roles (reverse)'; +} + done_testing;