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 ));
}
--- /dev/null
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Test::More;
+
+BEGIN {
+ eval "use Test::Output;";
+ plan skip_all => "Test::Output is required for this test" if $@;
+ plan tests => 1;
+}
+
+do {
+ package Parent;
+ sub new { bless {}, shift }
+
+ package Child;
+ BEGIN { our @ISA = 'Parent' }
+ use Mouse;
+};
+
+stderr_is(
+ sub { package Child; __PACKAGE__->meta->make_immutable },
+ "Not inlining a constructor for Child since it is not inheriting the default Mouse::Object constructor\n",
+ 'Mouse warns when it would have blown away the inherited constructor',
+);
+