Skip to content

Commit

Permalink
Remove special case
Browse files Browse the repository at this point in the history
Since the first element of .mro is the class itself, it will find its
own container_spec that way.
  • Loading branch information
lizmat committed Sep 24, 2019
1 parent 9636466 commit fe1dcad
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions src/Perl6/Metamodel/ContainerSpecProtocol.nqp
Expand Up @@ -10,22 +10,13 @@ role Perl6::Metamodel::ContainerSpecProtocol {
}

method publish_container_spec($obj) {
# If we have a container specification here, install that
if $!code_pair {
nqp::setcontspec($obj, 'code_pair', $!code_pair);
$obj.HOW.compose_repr($obj);
}

# look in the parents for any if none here
else {
for self.mro($obj) -> $class {
if nqp::can($class.HOW, 'get_container_spec') {
my $code_pair := $class.HOW.get_container_spec($class);
if $code_pair {
nqp::setcontspec($obj, 'code_pair', $code_pair);
$obj.HOW.compose_repr($obj);
last;
}
for self.mro($obj) -> $class {
if nqp::can($class.HOW, 'get_container_spec') {
my $code_pair := $class.HOW.get_container_spec($class);
if $code_pair {
nqp::setcontspec($obj, 'code_pair', $code_pair);
$obj.HOW.compose_repr($obj);
last;
}
}
}
Expand Down

0 comments on commit fe1dcad

Please sign in to comment.