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 );
$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);
$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(
'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;