From: Jesse Luehrs Date: Wed, 15 Apr 2009 03:23:29 +0000 (-0500) Subject: move validation (can't inherit from roles) from Moose::extends to X-Git-Tag: 0.75~15 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e2eef3a55ebd2bcee27681cc63b48b502b3ee812;p=gitmo%2FMoose.git move validation (can't inherit from roles) from Moose::extends to Moose::Meta::Class::superclasses --- diff --git a/lib/Moose.pm b/lib/Moose.pm index 3a9c6a5..50ac497 100644 --- a/lib/Moose.pm +++ b/lib/Moose.pm @@ -54,20 +54,10 @@ sub extends { Moose->throw_error("Must derive at least one class") unless @_; - my @supers = @_; - foreach my $super (@supers) { - my $meta = Class::MOP::load_class($super); - Moose->throw_error("You cannot inherit from a Moose Role ($super)") - if $meta && $meta->isa('Moose::Meta::Role') - } - - - # this checks the metaclass to make sure # it is correct, sometimes it can get out # of sync when the classes are being built - my $meta = Moose::Meta::Class->initialize($class); - $meta->superclasses(@supers); + Moose::Meta::Class->initialize($class)->superclasses(@_); } sub with { diff --git a/lib/Moose/Meta/Class.pm b/lib/Moose/Meta/Class.pm index ceec428..94459f2 100644 --- a/lib/Moose/Meta/Class.pm +++ b/lib/Moose/Meta/Class.pm @@ -202,6 +202,17 @@ sub _construct_instance { return $instance; } +sub superclasses { + my $self = shift; + my @supers = @_; + foreach my $super (@supers) { + my $meta = Class::MOP::load_class($super); + Moose->throw_error("You cannot inherit from a Moose Role ($super)") + if $meta && $meta->isa('Moose::Meta::Role') + } + return $self->SUPER::superclasses(@supers); +} + ### --------------------------------------------- sub add_attribute {