From: Jesse Luehrs Date: Mon, 27 Sep 2010 05:49:04 +0000 (-0500) Subject: oops, need to handle the "can't reinitialize" case here X-Git-Tag: 1.15~45 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=11ba7c34544d01f8179e603bb13eb36d49d65a0a;p=gitmo%2FMoose.git oops, need to handle the "can't reinitialize" case here --- diff --git a/lib/Moose/Meta/Class.pm b/lib/Moose/Meta/Class.pm index 37164ab..ccb6538 100644 --- a/lib/Moose/Meta/Class.pm +++ b/lib/Moose/Meta/Class.pm @@ -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); } diff --git a/t/050_metaclasses/015_metarole.t b/t/050_metaclasses/015_metarole.t index 6d80c50..b961bb1 100644 --- a/t/050_metaclasses/015_metarole.t +++ b/t/050_metaclasses/015_metarole.t @@ -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'); } { diff --git a/t/050_metaclasses/050_metarole_backcompat.t b/t/050_metaclasses/050_metarole_backcompat.t index 2ded6e4..bafc687 100644 --- a/t/050_metaclasses/050_metarole_backcompat.t +++ b/t/050_metaclasses/050_metarole_backcompat.t @@ -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'); } {