From: Shawn M Moore Date: Sun, 3 May 2009 19:25:44 +0000 (-0400) Subject: Handle pulling in a method from two different roles X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c3c1ebd65f123966666d7968ed177cff0869ce06;p=gitmo%2FPerl-Critic-Dynamic-Moose.git Handle pulling in a method from two different roles --- diff --git a/lib/Perl/Critic/Policy/DynamicMoose/ClassOverridesRole.pm b/lib/Perl/Critic/Policy/DynamicMoose/ClassOverridesRole.pm index 5fa76da..9f1c589 100644 --- a/lib/Perl/Critic/Policy/DynamicMoose/ClassOverridesRole.pm +++ b/lib/Perl/Critic/Policy/DynamicMoose/ClassOverridesRole.pm @@ -26,7 +26,9 @@ sub violates_metaclass { # no metadata, should check source role to make sure it's the # same as $role - next if $method_object->isa('Moose::Meta::Role::Method'); + if ($method_object->isa('Moose::Meta::Role::Method')) { + next if $method_object->original_package_name eq $role->name; + } my $class_name = $class->name; my $role_name = $role->name; diff --git a/t/DynamicMoose/ClassOverridesRole.run b/t/DynamicMoose/ClassOverridesRole.run index d5d8a15..75df069 100644 --- a/t/DynamicMoose/ClassOverridesRole.run +++ b/t/DynamicMoose/ClassOverridesRole.run @@ -47,3 +47,24 @@ with 'Role' => { excludes => 'foo' }; sub foo {} +#----------------------------------------------------------------------------- + +## name Name collision from two roles +## failures 1 +## cut + +package Role::A; +use Moose::Role; + +sub foo {} + +package Role::B; +use Moose::Role; + +sub foo {} + +package Class; +use Moose; +with 'Role::A'; +with 'Role::B'; +