From: Yuval Kogman Date: Fri, 26 Jun 2009 23:42:49 +0000 (-0400) Subject: accessor overwriting warning now reflects reality X-Git-Tag: 0.86~6 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1d18c898b5430bf0142c3c6e678429287c01b24e;p=gitmo%2FMoose.git accessor overwriting warning now reflects reality The error says you cannot overwrite the accessor, when it in fact just does get overwritten (and this behavior is necessary for backwards compatibility) --- diff --git a/lib/Moose/Meta/Attribute.pm b/lib/Moose/Meta/Attribute.pm index 31d96a3..c00e952 100644 --- a/lib/Moose/Meta/Attribute.pm +++ b/lib/Moose/Meta/Attribute.pm @@ -585,7 +585,7 @@ sub _process_accessors { && (!$self->definition_context || $method->package_name eq $self->definition_context->{package})) { Carp::cluck( - "You cannot overwrite a locally defined method ($accessor) with " + "You are overwriting a locally defined method ($accessor) with " . "an accessor" ); } diff --git a/t/020_attributes/027_accessor_override_method.t b/t/020_attributes/027_accessor_override_method.t index 22f562a..16ab21a 100644 --- a/t/020_attributes/027_accessor_override_method.t +++ b/t/020_attributes/027_accessor_override_method.t @@ -22,12 +22,12 @@ BEGIN { my $foo_meta = Foo->meta; stderr_like(sub { $foo_meta->add_attribute(a => (reader => 'get_a')) }, - qr/^You cannot overwrite a locally defined method \(get_a\) with an accessor/, 'reader overriding gives proper warning'); + qr/^You are overwriting a locally defined method \(get_a\) with an accessor/, 'reader overriding gives proper warning'); stderr_like(sub { $foo_meta->add_attribute(b => (writer => 'set_b')) }, - qr/^You cannot overwrite a locally defined method \(set_b\) with an accessor/, 'writer overriding gives proper warning'); + qr/^You are overwriting a locally defined method \(set_b\) with an accessor/, 'writer overriding gives proper warning'); stderr_like(sub { $foo_meta->add_attribute(c => (predicate => 'has_c')) }, - qr/^You cannot overwrite a locally defined method \(has_c\) with an accessor/, 'predicate overriding gives proper warning'); + qr/^You are overwriting a locally defined method \(has_c\) with an accessor/, 'predicate overriding gives proper warning'); stderr_like(sub { $foo_meta->add_attribute(d => (clearer => 'clear_d')) }, - qr/^You cannot overwrite a locally defined method \(clear_d\) with an accessor/, 'clearer overriding gives proper warning'); + qr/^You are overwriting a locally defined method \(clear_d\) with an accessor/, 'clearer overriding gives proper warning'); stderr_like(sub { $foo_meta->add_attribute(e => (is => 'rw')) }, - qr/^You cannot overwrite a locally defined method \(e\) with an accessor/, 'accessor overriding gives proper warning'); + qr/^You are overwriting a locally defined method \(e\) with an accessor/, 'accessor overriding gives proper warning');