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"