only warn if the attribute was defined in the same package as the method
Jesse Luehrs [Fri, 26 Jun 2009 03:27:09 +0000 (22:27 -0500)]
lib/Moose/Meta/Attribute.pm

index ec52e71..820c77a 100644 (file)
@@ -574,8 +574,10 @@ sub _process_accessors {
     my $self = shift;
     my ($type, $accessor, $generate_as_inline_methods) = @_;
     $accessor = (keys %$accessor)[0] if (ref($accessor)||'') eq 'HASH';
-    if ($self->associated_class->has_method($accessor)
-     && !$self->associated_class->get_method($accessor)->isa('Class::MOP::Method::Accessor')) {
+    my $method = $self->associated_class->get_method($accessor);
+    if ($method && !$method->isa('Class::MOP::Method::Accessor')
+     && (!$self->definition_context
+      || $method->package_name eq $self->definition_context->{package})) {
         Carp::cluck(
             "You cannot overwrite a locally defined method ($accessor) with "
           . "an accessor"