Skip to content

Commit

Permalink
Make .WHY on role group delegate to default role
Browse files Browse the repository at this point in the history
Roles have a two-level structure: the role name is a parametric role
group, which in turns contains the parametric role. In the case of there
being many roles of the same short name, they are within the one group.
Declarator docs correctly attach to the parametric role. However, that
means .WHY on the group doesn't actually result in those docs. You have
to extract the candidate from the group.

In many cases, however, we people ain't using parametric roles, and we
make many meta-operations delegate to the single or unsignatured role
candidate, if any. We do not currently do this for .WHY. This commit
makes us do so, BUT it turns out there are 3 current spectests that will
fail because they explicitly expect that not to happen. Thus, we need to
make a decision over whether we want this change.

Relates to #3521.
  • Loading branch information
jnthn committed Mar 13, 2020
1 parent ac012f1 commit a8f1e97
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions src/Perl6/Metamodel/ParametricRoleGroupHOW.nqp
Expand Up @@ -137,7 +137,7 @@ class Perl6::Metamodel::ParametricRoleGroupHOW
}

method update_role_typecheck_list($obj) {
my $ns := self.'!get_nonsignatured_candidate'($obj);
my $ns := self.'!get_nonsignatured_candidate'();
@!role_typecheck_list := $ns.HOW.role_typecheck_list($ns) unless nqp::isnull($ns);
}

Expand All @@ -160,48 +160,53 @@ class Perl6::Metamodel::ParametricRoleGroupHOW
return 1;
}
}
my $ns := self.'!get_nonsignatured_candidate'($obj);
my $ns := self.'!get_nonsignatured_candidate'();
return $ns.HOW.type_check_parents($ns, $decont) unless nqp::isnull($ns);
0;
}

method candidates($obj) { nqp::clone(@!candidates) }

method lookup($obj, $name) {
my $c := self.'!get_default_candidate'($obj);
my $c := self.'!get_default_candidate'();
$c.HOW.lookup($c, $name);
}

method methods($obj, *@pos, *%name) {
my $c := self.'!get_default_candidate'($obj);
my $c := self.'!get_default_candidate'();
$c.HOW.methods($c, |@pos, |%name);
}

method attributes($obj, *@pos, *%name) {
my $c := self.'!get_default_candidate'($obj);
my $c := self.'!get_default_candidate'();
$c.HOW.attributes($c, |@pos, |%name);
}

method roles($obj, *%named) {
my $c := self.'!get_default_candidate'($obj);
my $c := self.'!get_default_candidate'();
$c.HOW.roles($c, |%named)
}

method ver($obj) {
my $c := self.'!get_default_candidate'($obj);
my $c := self.'!get_default_candidate'();
$c.HOW.ver($c)
}

method auth($obj) {
my $c := self.'!get_default_candidate'($obj);
my $c := self.'!get_default_candidate'();
$c.HOW.auth($c)
}

method !get_default_candidate($obj) {
self.'!get_nonsignatured_candidate'($obj) || @!candidates[0]
method WHY() {
my $c := self.'!get_default_candidate'();
$c.HOW.WHY
}

method !get_nonsignatured_candidate($obj) {
method !get_default_candidate() {
self.'!get_nonsignatured_candidate'() || @!candidates[0]
}

method !get_nonsignatured_candidate() {
return nqp::null unless +@!nonsignatured;
@!nonsignatured[0]
}
Expand Down

0 comments on commit a8f1e97

Please sign in to comment.