Revert "Merge branch 'master' into topic/symbol-manipulator"
[gitmo/Class-MOP.git] / lib / Class / MOP / Class / Immutable / Trait.pm
index 29c79e8..a21d3a0 100644 (file)
@@ -39,7 +39,6 @@ sub remove_method         { _immutable_cannot_call() }
 sub add_attribute         { _immutable_cannot_call() }
 sub remove_attribute      { _immutable_cannot_call() }
 sub remove_package_symbol { _immutable_cannot_call() }
-sub add_package_symbol    { _immutable_cannot_call() }
 
 sub class_precedence_list {
     my $orig = shift;
@@ -84,6 +83,15 @@ sub get_method_map {
     $self->{__immutable}{get_method_map} ||= $self->$orig;
 }
 
+sub add_package_symbol {
+    my $orig = shift;
+    my $self = shift;
+    confess "Cannot add package symbols to an immutable metaclass"
+        unless ( caller(3) )[3] eq 'Class::MOP::Package::get_package_symbol';
+
+    $self->$orig(@_);
+}
+
 1;
 
 __END__