Check superclasses not to inherit from roles
gfx [Thu, 8 Oct 2009 10:14:52 +0000 (19:14 +0900)]
lib/Mouse/Meta/Class.pm

index ea36a4b..f418d6c 100644 (file)
@@ -48,7 +48,13 @@ sub superclasses {
     my $self = shift;
 
     if (@_) {
-        Mouse::load_class($_) for @_;
+        foreach my $super(@_){
+            Mouse::Util::load_class($super);
+            my $meta = Mouse::Util::get_metaclass_by_name($super);
+            if($meta && $meta->isa('Mouse::Meta::Role')){
+                $self->throw_error("You cannot inherit from a Mouse Role ($super)");
+            }
+        }
         @{ $self->{superclasses} } = @_;
     }