if (@_) {
foreach my $super(@_){
Mouse::Util::load_class($super);
- my $meta = Mouse::Util::get_metaclass_by_name($super);
- next if not defined $meta;
+ my $meta = Mouse::Util::get_metaclass_by_name($super);
+ unless(defined $meta) {
+ # checks if $super is a foreign class (i.e. non-Mouse class)
+ my $mm = $super->can('meta');
+ if(!($mm && $mm == \&Mouse::Util::meta)) {
+ if($super->can('new') or $super->can('DESTROY')) {
+ $self->inherit_from_foreign_class($super);
+ }
+ }
+ next;
+ }
if(Mouse::Util::is_a_metarole($meta)){
$self->throw_error("You cannot inherit from a Mouse Role ($super)");
}
+ # checks and fixes in metaclass compatiility
next if $self->isa(ref $meta); # _superclass_meta_is_compatible
-
$self->_reconcile_with_superclass_meta($meta);
}
@{ $self->{superclasses} } = @_;
return @{ $self->{superclasses} };
}
+
+sub inherit_from_foreign_class {
+ my($class, $super) = @_;
+ Carp::carp("You inherit from non-Mouse class ($super),"
+ . " but it is unlikely to work correctly."
+ . " Please concider to use MouseX::Foreign");
+ return;
+}
+
my @MetaClassTypes = (
'attribute', # Mouse::Meta::Attribute
'method', # Mouse::Meta::Method