From: Dave Rolsky Date: Fri, 16 Sep 2011 15:42:37 +0000 (-0500) Subject: Don't warn when overriding a stub method with an accessor X-Git-Tag: 2.0300~62 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5bfb3fa40c5f9c50efd1d9768a6d634b0bcc0169;p=gitmo%2FMoose.git Don't warn when overriding a stub method with an accessor --- diff --git a/lib/Moose/Meta/Attribute.pm b/lib/Moose/Meta/Attribute.pm index e347197..7f35161 100644 --- a/lib/Moose/Meta/Attribute.pm +++ b/lib/Moose/Meta/Attribute.pm @@ -1037,6 +1037,7 @@ sub _process_accessors { if ( $method + && !$method->is_stub && !$method->isa('Class::MOP::Method::Accessor') && ( !$self->definition_context || $method->package_name eq $self->definition_context->{package} ) diff --git a/t/attributes/accessor_override_method.t b/t/attributes/accessor_override_method.t index 5c12716..b449591 100644 --- a/t/attributes/accessor_override_method.t +++ b/t/attributes/accessor_override_method.t @@ -17,6 +17,7 @@ use Test::Requires { sub has_c { } sub clear_d { } sub e { } + sub stub; } my $foo_meta = Foo->meta; @@ -45,6 +46,11 @@ stderr_like( qr/^You are overwriting a locally defined method \(e\) with an accessor/, 'accessor overriding gives proper warning' ); +stderr_is( + sub { $foo_meta->add_attribute( stub => ( is => 'rw' ) ) }, + q{}, + 'overriding a stub with an accessor does not warn' +); stderr_like( sub { $foo_meta->add_attribute( has => ( is => 'rw' ) ) }, qr/^You are overwriting a locally defined function \(has\) with an accessor/,