Skip to content

Commit

Permalink
Export packages by user given names
Browse files Browse the repository at this point in the history
For `class A::B is export { }` the export trait would use `B::C` part
even if the class is declared inside another named package.

Solves Raku/problem-solving#142
  • Loading branch information
vrurg committed Dec 29, 2019
1 parent 5c65a12 commit 5786026
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/Perl6/Grammar.nqp
Expand Up @@ -1917,6 +1917,7 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
rule package_def {
:my $longname;
:my $outer := $*W.cur_lexpad();
:my $*DECLARATION_NAME;
:my $*IMPLICIT := 0;
:my $*DECLARAND;
:my $*CODE_OBJECT := $*W.stub_code_object($*PKGDECL eq 'role' ?? 'Sub' !! 'Block');
Expand Down Expand Up @@ -1944,7 +1945,8 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
<!!{ $/.clone_braid_from(self) }>
[
[ <longname> { $longname := $*W.dissect_longname($<longname>); } ]?
[ <longname> { $longname := $*W.dissect_longname($<longname>);
$*DECLARATION_NAME := nqp::hllizefor($longname.name(), 'perl6'); } ]?
<.newpad>
[ :dba('generic role')
Expand Down
4 changes: 2 additions & 2 deletions src/core.c/traits.pm6
Expand Up @@ -18,7 +18,7 @@ multi sub trait_mod:<is>(Mu:U $child, Mu:U $parent) {
}
elsif $parent.HOW.archetypes.inheritalizable() {
if nqp::can($parent.HOW, 'methods')
&& my @required-methods = $parent.^methods.grep({$_.yada})
&& my @required-methods = $parent.^methods.grep({$_.yada})
{
my $type = $child.HOW.archetypes.inheritable()
?? 'Class '
Expand Down Expand Up @@ -288,7 +288,7 @@ multi sub trait_mod:<is>(Routine:D \r, :$export!, :$SYMBOL = '&' ~ r.name) {
Rakudo::Internals.EXPORT_SYMBOL(nqp::decont($SYMBOL), @tags, $to_export);
}
multi sub trait_mod:<is>(Mu:U \type, :$export!) {
my $exp_name := type.^shortname;
my $exp_name := $*DECLARATION_NAME // type.^shortname;
my @tags = flat 'ALL', (
nqp::istype($export,Pair)
?? $export.key()
Expand Down

0 comments on commit 5786026

Please sign in to comment.