X-Git-Url: https://perl5.git.perl.org/perl5.git/blobdiff_plain/5565990ae7d1a23693f78cbe611ec2a5af8dd5e1..042560a65fd56038b3116f30639cb99d98c48622:/lib/base.pm diff --git a/lib/base.pm b/lib/base.pm index fc0f7f9..be4c667 100644 --- a/lib/base.pm +++ b/lib/base.pm @@ -71,12 +71,13 @@ sub import { my $inheritor = caller(0); my @isa_classes; + my @bases; foreach my $base (@_) { if ( $inheritor eq $base ) { warn "Class '$inheritor' tried to inherit from itself\n"; } - next if $inheritor->isa($base); + next if grep $_->isa($base), ($inheritor, @bases); if (has_version($base)) { ${$base.'::VERSION'} = '-1, set by base.pm' @@ -99,14 +100,14 @@ Base class package "$base" is empty. or make that module available in \@INC (\@INC contains: @INC). ERROR } - $sigdie = $SIG{__DIE__}; + $sigdie = $SIG{__DIE__} || undef; } # Make sure a global $SIG{__DIE__} makes it out of the localization. $SIG{__DIE__} = $sigdie if defined $sigdie; ${$base.'::VERSION'} = "-1, set by base.pm" unless defined ${$base.'::VERSION'}; } - push @isa_classes, $base; + push @bases, $base; if ( has_fields($base) || has_attr($base) ) { # No multiple fields inheritance *suck* @@ -121,6 +122,8 @@ ERROR # Save this until the end so it's all or nothing if the above loop croaks. push @{"$inheritor\::ISA"}, @isa_classes; + push @{"$inheritor\::ISA"}, @bases; + if( defined $fields_base ) { inherit_fields($inheritor, $fields_base); }