while ($method->isa('Class::MOP::Method::Wrapped')) {
$method = $method->get_original_method;
}
- return 1 if !$method->isa('Class::MOP::Method::Accessor');
- return 0 if !$self->definition_context;
+ return 0 if $method->isa('Class::MOP::Method::Accessor');
+ return 1 if !$self->definition_context;
return 0 if $method->package_name ne $self->definition_context->{package};
- return 0;
+ return 1;
}
sub _process_accessors {
if ($self->_looks_like_overwriting_local_method($accessor)) {
Carp::cluck(
"You are overwriting a locally defined method ($accessor) with "
- . "an accessor at line " .$self->definition_context->{line}
+ . "an accessor"
);
}
$self->SUPER::_process_accessors(@_);
--- /dev/null
+#!/usr/bin/env perl
+use strict;
+use Test::More;
+
+BEGIN {
+ eval "use Test::Output;";
+ plan skip_all => "Test::Output is required for this test" if $@;
+ plan tests => 1;
+}
+
+{
+
+ package Role;
+ use Moose::Role;
+
+ has value => (
+ is => 'rw',
+ clearer => 'clear_value',
+ );
+
+ after clear_value => sub { };
+}
+{
+
+ package Class;
+ use Moose;
+
+ with 'Role';
+ has '+value' => ( isa => q[Str] );
+}
+
+stderr_unlike(sub { Class->new; },
+ qr/^You are overwriting a locally defined method \(get_a\) with an accessor/, 'reader overriding gives proper warning');