Skip to content
Browse files

Add a safeguard against class A is A

  • Loading branch information...
1 parent 92aafcb commit cc7b41efc6c1a0907a7a5e0a9ae1af701c0cbc88 @sorear committed Dec 27, 2010
Showing with 8 additions and 0 deletions.
  1. +8 −0 src/Metamodel.pm
View
8 src/Metamodel.pm
@@ -278,6 +278,7 @@ our %units;
has superclasses => (isa => 'ArrayRef', is => 'ro',
default => sub { [] });
has linearized_mro => (isa => 'ArrayRef[ArrayRef]', is => 'rw');
+ has _closing => (isa => 'Bool', is => 'rw');
sub add_attribute {
my ($self, $name) = @_;
@@ -298,6 +299,13 @@ our %units;
sub close {
my ($self) = @_;
+
+ return if $self->linearized_mro;
+ if ($self->_closing) {
+ die "Class hierarchy circularty detected at ", $self->name, "\n";
+ }
+ $self->_closing(1);
+
if (($self->name ne 'Mu' || !$unit->is_true_setting)
&& !@{ $self->superclasses }) {
$self->add_super($unit->get_item(

0 comments on commit cc7b41e

Please sign in to comment.
Something went wrong with that request. Please try again.