Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[mm] Implement automatic subclassing of Any
  • Loading branch information
sorear committed Sep 19, 2010
1 parent a7ff91c commit 31b2aaa
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Metamodel.pm
Expand Up @@ -72,6 +72,8 @@ our $global;
die "superclass $super->name defined in a lowly package";
}

sub close { }

no Moose;
__PACKAGE__->meta->make_immutable;
}
Expand Down Expand Up @@ -114,6 +116,17 @@ our $global;
push @{ $self->superclasses }, $targ;
}

sub close {
my ($self, $targ) = @_;
# XXX should probably check that these are CORE::Mu and CORE::Any
if ($self->name ne 'Mu' && !@{ $self->superclasses }) {
$self->add_super($opensubs[-1]->find_lex($self->_defsuper)
->referent->obj);
}
}

sub _defsuper { 'Any' }

no Moose;
__PACKAGE__->meta->make_immutable;
}
Expand Down Expand Up @@ -375,6 +388,7 @@ sub Op::PackageDef::begin {
if (!$self->stub) {
my $obj = $pclass->new(name => $self->name);
my $body = $self->body->begin(body_of => $obj, once => 1);
$obj->close;
$ns->obj($obj);
$opensubs[-1]->add_my_sub($self->bodyvar, $body);
}
Expand Down

0 comments on commit 31b2aaa

Please sign in to comment.