warn if we try to overwrite a local function with an accessor
[gitmo/Moose.git] / lib / Moose / Meta / Attribute.pm
index dfdfbbe..1e84937 100644 (file)
@@ -574,6 +574,13 @@ sub _process_accessors {
           . "an accessor"
         );
     }
+    if (!$self->associated_class->has_method($accessor)
+     && $self->associated_class->has_package_symbol('&' . $accessor)) {
+        Carp::cluck(
+            "You are overwriting a locally defined function ($accessor) with "
+          . "an accessor"
+        );
+    }
     $self->SUPER::_process_accessors(@_);
 }