Handle pulling in a method from two different roles
Shawn M Moore [Sun, 3 May 2009 19:25:44 +0000 (15:25 -0400)]
lib/Perl/Critic/Policy/DynamicMoose/ClassOverridesRole.pm
t/DynamicMoose/ClassOverridesRole.run

index 5fa76da..9f1c589 100644 (file)
@@ -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;
index d5d8a15..75df069 100644 (file)
@@ -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';
+