Include the class name in the method-less attribute message
[gitmo/Moose.git] / lib / Moose / Meta / Attribute.pm
index ec52e71..25b94cb 100644 (file)
@@ -7,7 +7,7 @@ use warnings;
 use Scalar::Util 'blessed', 'weaken';
 use overload     ();
 
-our $VERSION   = '0.83';
+our $VERSION   = '0.84';
 our $AUTHORITY = 'cpan:STEVAN';
 
 use Moose::Meta::Method::Accessor;
@@ -562,7 +562,9 @@ sub install_accessors {
         || ($self->_is_metadata || '') eq 'bare'
     ) {
         Carp::cluck(
-            'Attribute (' . $self->name . ') has no associated methods'
+            'Attribute (' . $self->name . ') of class '
+            . $self->associated_class->name
+            . ' has no associated methods'
             . ' (did you mean to provide an "is" argument?)'
             . "\n"
         )
@@ -574,8 +576,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"