From: Jesse Luehrs Date: Thu, 9 Apr 2009 00:49:15 +0000 (-0500) Subject: warn if we aren't going to inline a constructor because one is already X-Git-Tag: 0.82~8 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=78a0df3a92aefcde0a9bef94cb50bb1c05b4a8b9;p=gitmo%2FClass-MOP.git warn if we aren't going to inline a constructor because one is already there --- diff --git a/lib/Class/MOP/Immutable.pm b/lib/Class/MOP/Immutable.pm index c119db0..e1f279a 100644 --- a/lib/Class/MOP/Immutable.pm +++ b/lib/Class/MOP/Immutable.pm @@ -97,11 +97,18 @@ sub _inline_constructor { return unless $self->options->{inline_constructor}; - return - unless $self->options->{replace_constructor} - or !$self->metaclass->has_method( - $self->options->{constructor_name} - ); + unless ($self->options->{replace_constructor} + or !$self->metaclass->has_method( + $self->options->{constructor_name} + )) { + my $class = $self->metaclass->name; + warn "Not inlining a constructor for $class since it defines" + . " its own constructor.\n" + . "If you are certain you don't need to inline your" + . " constructor, specify inline_constructor => 0 in your" + . " call to $class->meta->make_immutable\n"; + return; + } my $constructor_class = $self->options->{constructor_class};