summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2011-03-02 00:43:25 -0600
committerJesse Luehrs <doy@tozt.net>2011-03-02 00:43:25 -0600
commitdc072f08418d6b918bd35c97a1884298de5dfdaf (patch)
treea9637986986d8e56c2458655ff75f22ff08ab8b8 /lib
parent483965342b368093c04e5d5e2bbf4b0c2c610ebb (diff)
downloadmoosex-nonmoose-dc072f08418d6b918bd35c97a1884298de5dfdaf.tar.gz
moosex-nonmoose-dc072f08418d6b918bd35c97a1884298de5dfdaf.zip
warn instead of die if the superclass has a DESTROY but no new
Diffstat (limited to 'lib')
-rw-r--r--lib/MooseX/NonMoose/Meta/Role/Class.pm15
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/MooseX/NonMoose/Meta/Role/Class.pm b/lib/MooseX/NonMoose/Meta/Role/Class.pm
index 1d1796a..6c09b22 100644
--- a/lib/MooseX/NonMoose/Meta/Role/Class.pm
+++ b/lib/MooseX/NonMoose/Meta/Role/Class.pm
@@ -57,14 +57,25 @@ sub _determine_constructor_options {
unless $cc_meta->can('does_role')
&& $cc_meta->does_role('MooseX::NonMoose::Meta::Role::Constructor');
+ # XXX: get constructor name from the constructor metaclass?
+ my $local_constructor = $self->get_method('new');
+ if (!defined($local_constructor)) {
+ warn "Not inlining a constructor for " . $self->name . " since "
+ . "its parent " . ($self->superclasses)[0] . " doesn't contain a "
+ . "'new' method. "
+ . "If you are certain you don't need to inline your"
+ . " constructor, specify inline_constructor => 0 in your"
+ . " call to " . $self->name . "->meta->make_immutable\n";
+ return @options;
+ }
+
# do nothing if extends was called, but we then added a method modifier to
# the constructor (this will warn, but that's okay)
# XXX: this is a fairly big hack, but it should cover most of the cases
# that actually show up in practice... it would be nice to do this properly
# though
- # XXX: get constructor name from the constructor metaclass?
return @options
- if $self->get_method('new')->isa('Class::MOP::Method::Wrapped');
+ if $local_constructor->isa('Class::MOP::Method::Wrapped');
# do nothing if we explicitly ask for the constructor to not be inlined
my %options = @options;