From: Jesse Luehrs Date: Fri, 26 Jun 2009 03:27:09 +0000 (-0500) Subject: only warn if the attribute was defined in the same package as the method X-Git-Tag: 0.84~8 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=99541dfddce873d9e7186b75ba066bec2bd692c2;p=gitmo%2FMoose.git only warn if the attribute was defined in the same package as the method --- diff --git a/lib/Moose/Meta/Attribute.pm b/lib/Moose/Meta/Attribute.pm index ec52e71..820c77a 100644 --- a/lib/Moose/Meta/Attribute.pm +++ b/lib/Moose/Meta/Attribute.pm @@ -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"