Check body, because original_package_name may be a different role master
Shawn M Moore [Sun, 3 May 2009 21:42:51 +0000 (17:42 -0400)]
lib/Perl/Critic/Policy/DynamicMoose/ClassOverridesRole.pm
t/DynamicMoose/ClassOverridesRole.run

index 94b19dd..3b5d040 100644 (file)
@@ -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;
index 1a62da9..3680ee3 100644 (file)
@@ -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';
+