Don't throw an error when a delegation overrides a stub
Dave Rolsky [Fri, 16 Sep 2011 15:50:00 +0000 (10:50 -0500)]
lib/Moose/Meta/Attribute.pm

index e97a5df..5b78fd4 100644 (file)
@@ -1084,10 +1084,12 @@ sub install_delegation {
         my $class_name = $associated_class->name;
         my $name = "${class_name}::${handle}";
 
-        ( !$associated_class->has_method($handle) )
-            || $self->throw_error(
-            "You cannot overwrite a locally defined method ($handle) with a delegation",
-            method_name => $handle );
+        if ( my $method = $associated_class->get_method($handle) ) {
+            $self->throw_error(
+                "You cannot overwrite a locally defined method ($handle) with a delegation",
+                method_name => $handle
+            ) unless $method->is_stub;
+        }
 
         # NOTE:
         # handles is not allowed to delegate