oops, need to handle the "can't reinitialize" case here
Jesse Luehrs [Mon, 27 Sep 2010 05:49:04 +0000 (00:49 -0500)]
lib/Moose/Meta/Class.pm
t/050_metaclasses/015_metarole.t
t/050_metaclasses/050_metarole_backcompat.t

index 37164ab..ccb6538 100644 (file)
@@ -580,6 +580,15 @@ sub _get_compatible_single_metaclass_by_role_reconciliation {
 
     my $current_single_meta_name = $self->_get_associated_single_metaclass($single_meta_name);
 
+    # XXX: gross
+    return unless $self->_classes_differ_by_roles_only(
+        $single_meta_name,
+        $current_single_meta_name,
+        $single_meta_name->isa('Class::MOP::Attribute')
+            ? 'Moose::Meta::Attribute'
+            : 'Moose::Meta::Method'
+    );
+
     return Moose::Util::_reconcile_roles_for_metaclass($single_meta_name, $current_single_meta_name);
 }
 
index 6d80c50..b961bb1 100644 (file)
@@ -98,6 +98,10 @@ use Moose::Util::MetaRole;
     My::Class->meta()->add_after_method_modifier( 'bar' => sub { 'bar' } );
     is( My::Class->meta()->get_method('bar')->foo(), 10,
         '... call foo() on a wrapped method metaclass object' );
+    # so that it doesn't break on reinitialization, since it's a
+    # Class::MOP::Method::Wrapped object, which isn't a Moose::Meta::Method
+    # object. Someday we'll fix this...
+    My::Class->meta()->remove_method('bar');
 }
 
 {
index 2ded6e4..bafc687 100644 (file)
@@ -105,6 +105,10 @@ use Moose::Util::MetaRole;
     My::Class->meta()->add_after_method_modifier( 'bar' => sub { 'bar' } );
     is( My::Class->meta()->get_method('bar')->foo(), 10,
         '... call foo() on a wrapped method metaclass object' );
+    # so that it doesn't break on reinitialization, since it's a
+    # Class::MOP::Method::Wrapped object, which isn't a Moose::Meta::Method
+    # object. Someday we'll fix this...
+    My::Class->meta()->remove_method('bar');
 }
 
 {