Reputation: 23537
There does not seem to be a way to use new_type in MetamodelConcreteRoleHOW, which as its name implies should be used to create new instances of a Role. The main problem is when you try to mix-in new roles, as implied by the signature ( method new_type(:@roles, :$name = '<anon>', :$ver, :$auth, :$repr, :$api)
):
my $a = Metamodel::ConcreteRoleHOW.new_type(name => "Bar", roles => [Iterable]);
$a.^compose;
say $a.^roles;
# Error: «Cannot iterate object with P6opaque representation (Array)
Using another Positional
, a list, yields a different error:
my $a = Metamodel::ConcreteRoleHOW.new_type(name => "Bar", roles => (Iterable));
$a.^compose;
say $a.^roles
# « Cannot iterate over a Iterable type object»
Beats me what kind of positional could I use there. To be sure, this is implemented in NQP, so maybe I should be defining an NQP array. But I really have no idea. Any help will be appreciated.
Edit. First, the error happens when you call compose
. Second, you effectively have to use an NQP array as Raiph says
use nqp;
my $roles := nqp::list(Iterable);
my $a = Metamodel::ConcreteRoleHOW.new_type(name => "Bar", roles => $roles);
$a.^compose;
say $a.^is_composed();
say $a.^roles # OUTPUT: «1(Mu)»
compose
works now, and it is actually composed, but the roles composed still show only the ur-role, Mu, not Iterable
which is the one that should have been added to it. Any idea?
Upvotes: 5
Views: 100