From: Matt S Trout Date: Sat, 5 May 2012 18:46:14 +0000 (+0000) Subject: exclude union roles and same-role-as-self from metaclass inflation X-Git-Tag: v0.091002~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a3411285078bba94ab2f354d78e68c7f441687b4;p=gitmo%2FMoo.git exclude union roles and same-role-as-self from metaclass inflation --- diff --git a/Changes b/Changes index 277b9dd..339aa83 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,4 @@ + - exclude union roles and same-role-as-self from metaclass inflation - inhale Moose roles before checking for composition conflicts - enable Moo::sification if only Moo::Role is loaded and not Moo - preserve attribute ordering diff --git a/lib/Moo/HandleMoose.pm b/lib/Moo/HandleMoose.pm index 6540ec2..0f87ec9 100644 --- a/lib/Moo/HandleMoose.pm +++ b/lib/Moo/HandleMoose.pm @@ -113,7 +113,7 @@ sub inject_real_metaclass_for { ); } $meta->add_role(Class::MOP::class_of($_)) - for grep $_ ne $name, + for grep !/\|/ && $_ ne $name, # reject Foo|Bar and same-role-as-self do { no warnings 'once'; keys %{$Role::Tiny::APPLIED_TO{$name}} }; $DID_INJECT{$name} = 1; $meta; diff --git a/lib/Moo/Role.pm b/lib/Moo/Role.pm index 080ba92..34203a8 100644 --- a/lib/Moo/Role.pm +++ b/lib/Moo/Role.pm @@ -36,7 +36,9 @@ sub _inhale_if_moose { if (!$INFO{$role} and $INC{"Moose.pm"}) { if (my $meta = Class::MOP::class_of($role)) { $INFO{$role}{methods} = { - map +($_ => $role->can($_)), $meta->get_method_list + map +($_ => $role->can($_)), + grep !$meta->get_method($_)->isa('Class::MOP::Method::Meta'), + $meta->get_method_list }; $Role::Tiny::APPLIED_TO{$role} = { map +($_->name => 1), $meta->calculate_all_roles