diff --git a/src/Perl6/Grammar.nqp b/src/Perl6/Grammar.nqp index f4c98f4cbd4..d9cd244a365 100644 --- a/src/Perl6/Grammar.nqp +++ b/src/Perl6/Grammar.nqp @@ -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'); @@ -1944,7 +1945,8 @@ grammar Perl6::Grammar is HLL::Grammar does STD { [ - [ { $longname := $*W.dissect_longname($); } ]? + [ { $longname := $*W.dissect_longname($); + $*DECLARATION_NAME := nqp::hllizefor($longname.name(), 'perl6'); } ]? <.newpad> [ :dba('generic role') @@ -2880,6 +2882,7 @@ grammar Perl6::Grammar is HLL::Grammar does STD { token type_declarator:sym { <.kok> :my $*IN_DECL := 'enum'; + :my $*DECLARATION_NAME; :my $*DOC := $*DECLARATOR_DOCS; { $*DECLARATOR_DOCS := '' } :my $*POD_BLOCK; @@ -2902,6 +2905,7 @@ grammar Perl6::Grammar is HLL::Grammar does STD { symbol => $longname.name(), ); } + $*DECLARATION_NAME := nqp::hllizefor($longname.name(), 'perl6'); } | | @@ -2916,6 +2920,7 @@ grammar Perl6::Grammar is HLL::Grammar does STD { rule type_declarator:sym { <.kok> :my $*IN_DECL := 'subset'; + :my $*DECLARATION_NAME; :my $*DOC := $*DECLARATOR_DOCS; { $*DECLARATOR_DOCS := '' } :my $*POD_BLOCK; @@ -2940,6 +2945,7 @@ grammar Perl6::Grammar is HLL::Grammar does STD { symbol => $longname.name(), ); } + $*DECLARATION_NAME := nqp::hllizefor($longname.name(), 'perl6'); } ]? { $*IN_DECL := '' } diff --git a/src/Perl6/World.nqp b/src/Perl6/World.nqp index 8181c1c7481..5abba731707 100644 --- a/src/Perl6/World.nqp +++ b/src/Perl6/World.nqp @@ -1536,7 +1536,17 @@ class Perl6::World is HLL::World { if $need-decont && nqp::islt_i(nqp::index('$&', nqp::substr($key,0,1)),0) { $value := nqp::decont($value); } - if $target.symbol($key) -> %sym { + my $is-packagy := 0; + if $!unit_ready && !nqp::isconcrete($value) { + my $valueHOW := $value.HOW; + $is-packagy := nqp::istype($valueHOW, self.find_symbol(['Metamodel', 'Naming'], :setting-only)) + && nqp::istype($valueHOW, self.find_symbol(['Metamodel', 'Stashing'], :setting-only)); + } + if $is-packagy { + # $pkgdecl parameter will never be used by install_package. 'packagy' is just a stub here. + self.install_package($/, nqp::split('::', $key), 'my', 'packagy', $*PACKAGE, $target, $value); + } + elsif $target.symbol($key) -> %sym { # There's already a symbol. However, we may be able to merge # if both are multis and have onlystar dispatchers. my $installed := %sym; diff --git a/src/core.c/operators.pm6 b/src/core.c/operators.pm6 index 541afd29427..d2171379422 100644 --- a/src/core.c/operators.pm6 +++ b/src/core.c/operators.pm6 @@ -603,7 +603,7 @@ sub INDIRECT_NAME_LOOKUP($root, *@chunks) is raw { ) } -sub REQUIRE_IMPORT($compunit, $existing-path,$top-existing-pkg,$stubname, *@syms --> Nil) { +sub REQUIRE_IMPORT($compunit, $existing-path, $top-existing-pkg, $stubname, *@syms --> Nil) { my $handle := $compunit.handle; my $DEFAULT := $handle.export-package().WHO; my $GLOBALish := $handle.globalish-package; diff --git a/src/core.c/traits.pm6 b/src/core.c/traits.pm6 index 04a65d2faa2..9fee767f403 100644 --- a/src/core.c/traits.pm6 +++ b/src/core.c/traits.pm6 @@ -288,7 +288,7 @@ multi sub trait_mod:(Routine:D \r, :$export!, :$SYMBOL = '&' ~ r.name) { Rakudo::Internals.EXPORT_SYMBOL(nqp::decont($SYMBOL), @tags, $to_export); } multi sub trait_mod:(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()