Ensure that we're not blowing away an inherited constructor
[gitmo/Mouse.git] / lib / Mouse / Meta / Class.pm
index f09cdaa..cd23c63 100644 (file)
@@ -148,7 +148,14 @@ sub make_immutable {
     my %args = @_;
     my $name = $self->name;
     $self->{is_immutable}++;
-    $self->add_method('new' => Mouse::Meta::Method::Constructor->generate_constructor_method_inline( $self ));
+
+    if ($self->name->can('new') != Mouse::Object->can('new')) {
+        warn "Not inlining a constructor for ".$self->name." since it is not inheriting the default Mouse::Object constructor\n";
+    }
+    else {
+        $self->add_method('new' => Mouse::Meta::Method::Constructor->generate_constructor_method_inline( $self ));
+    }
+
     if ($args{inline_destructor}) {
         $self->add_method('DESTROY' => Mouse::Meta::Method::Destructor->generate_destructor_method_inline( $self ));
     }
@@ -160,38 +167,10 @@ sub is_immutable { $_[0]->{is_immutable} }
 
 sub attribute_metaclass { "Mouse::Meta::Class" }
 
-sub _install_fast_modifier {
-    my $self     = shift;
-    my $into     = shift;
-    my $type     = shift;
-    my $modifier = pop;
-
-    foreach my $name (@_) {
-        my $method = Data::Util::get_code_ref( $into, $name );
-
-        if ( !$method || !Data::Util::subroutine_modifier($method) ) {
-
-            unless ($method) {
-                $method = $into->can($name)
-                    or confess "The method '$name' is not found in the inheritance hierarchy for class $into";
-            }
-            $method = Data::Util::modify_subroutine( $method,
-                $type => [$modifier] );
-
-            no warnings 'redefine';
-            Data::Util::install_subroutine( $into, $name => $method );
-        }
-        else {
-            Data::Util::subroutine_modifier( $method, $type => $modifier );
-        }
-    }
-    return;
-}
-
 sub _install_modifier {
     my ( $self, $into, $type, $name, $code ) = @_;
-    if (eval "require Data::Util; 1") {
-        $self->_install_fast_modifier( 
+    if (eval "require Class::Method::Modifiers::Fast; 1") {
+        Class::Method::Modifiers::Fast::_install_modifier( 
             $into,
             $type,
             $name,