From: Shawn M Moore Date: Sun, 3 May 2009 21:42:51 +0000 (-0400) Subject: Check body, because original_package_name may be a different role X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=HEAD;p=gitmo%2FPerl-Critic-Dynamic-Moose.git Check body, because original_package_name may be a different role --- diff --git a/lib/Perl/Critic/Policy/DynamicMoose/ClassOverridesRole.pm b/lib/Perl/Critic/Policy/DynamicMoose/ClassOverridesRole.pm index 94b19dd..3b5d040 100644 --- a/lib/Perl/Critic/Policy/DynamicMoose/ClassOverridesRole.pm +++ b/lib/Perl/Critic/Policy/DynamicMoose/ClassOverridesRole.pm @@ -26,7 +26,7 @@ sub violates_metaclass { or next; if ($method_object->isa('Moose::Meta::Role::Method')) { - next if $method_object->original_package_name eq $role->name; + next if $method_object->body == $role->get_method($method)->body; } my $class_name = $class->name; diff --git a/t/DynamicMoose/ClassOverridesRole.run b/t/DynamicMoose/ClassOverridesRole.run index 1a62da9..3680ee3 100644 --- a/t/DynamicMoose/ClassOverridesRole.run +++ b/t/DynamicMoose/ClassOverridesRole.run @@ -85,3 +85,29 @@ with 'Role' => { alias => { foo => 'foo_bar' } }; sub foo {} + +#----------------------------------------------------------------------------- + +## name Collision via same role +## failures 0 +## cut + +package Ur::Role; +use Moose::Role; + +sub foo { die "yawr" } + +package Role::Refined; +use Moose::Role; +with 'Ur::Role'; + +package Role::Distinguished; +use Moose::Role; +with 'Ur::Role'; + +package Class; +use Moose; + +with 'Role::Refined'; +with 'Role::Distinguished'; +