Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Allow for mixing into enums.
Fixes Bool but role {} and t/spec/S14-roles/mixin.t regressions
  • Loading branch information
niner committed Oct 3, 2015
1 parent fe41cd7 commit db729c1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Perl6/Metamodel/BOOTSTRAP.nqp
Expand Up @@ -2704,7 +2704,7 @@ BEGIN {
# class Bool is Int {
# has str $!key;
# has int $!value;
Bool.HOW.set_base_type(Bool, Int);
Bool.HOW.add_parent(Bool, Int);
Bool.HOW.add_attribute(Bool, BOOTSTRAPATTR.new(:name<$!key>, :type(str), :package(Bool)));
Bool.HOW.add_attribute(Bool, BOOTSTRAPATTR.new(:name<$!value>, :type(int), :package(Bool)));
Bool.HOW.set_boolification_mode(Bool, 1);
Expand Down
11 changes: 7 additions & 4 deletions src/Perl6/Metamodel/EnumHOW.nqp
Expand Up @@ -10,10 +10,12 @@ class Perl6::Metamodel::EnumHOW
does Perl6::Metamodel::MethodContainer
does Perl6::Metamodel::MultiMethodContainer
does Perl6::Metamodel::RoleContainer
does Perl6::Metamodel::BaseType
does Perl6::Metamodel::MultipleInheritance
does Perl6::Metamodel::C3MRO
does Perl6::Metamodel::MROBasedMethodDispatch
does Perl6::Metamodel::MROBasedTypeChecking
does Perl6::Metamodel::BUILDPLAN
does Perl6::Metamodel::Mixins
does Perl6::Metamodel::BoolificationProtocol
does Perl6::Metamodel::REPRComposeProtocol
does Perl6::Metamodel::InvocationProtocol
Expand Down Expand Up @@ -50,11 +52,12 @@ class Perl6::Metamodel::EnumHOW
nqp::findmethod(NQPMu, 'BUILDALL')(nqp::create(self), |%named)
}

method new_type(:$name!, :$base_type?) {
method new_type(:$name!, :$repr = 'P6opaque', :$base_type?) {
my $meta := self.new();
my $obj := nqp::settypehll(nqp::newtype($meta, 'P6opaque'), 'perl6');
my $obj := nqp::settypehll(nqp::newtype($meta, $repr), 'perl6');
$meta.set_name($obj, $name);
$meta.set_base_type($meta, $base_type) unless $base_type =:= NQPMu;
$meta.add_parent($meta, $base_type) unless $base_type =:= NQPMu;
$meta.setup_mixin_cache($obj);
self.add_stash($obj);
}

Expand Down

0 comments on commit db729c1

Please sign in to comment.