Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Harden export trait a bit to avoid hard to find issues.
  • Loading branch information
jnthn committed Aug 7, 2011
1 parent c7b6534 commit 31e7121
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/core/traits.pm
Expand Up @@ -38,8 +38,12 @@ multi trait_mod:<is>(Parameter:D $param, :$copy!) {
# full-blown serialization, though.
multi trait_mod:<is>(Routine:D \$r, :$export!) {
if %*COMPILING {
if $r.multi {
die "Cannot export an individual multi candidate; export the proto instead";
}
my @tags = 'ALL', 'DEFAULT';
for @tags -> $tag {
my $exp_name := '&' ~ $r.name;
my $install_in;
if $*EXPORT.WHO.exists($tag) {
$install_in := $*EXPORT.WHO.{$tag};
Expand All @@ -49,7 +53,10 @@ multi trait_mod:<is>(Routine:D \$r, :$export!) {
$*ST.pkg_compose($install_in);
$*ST.install_package_symbol($*EXPORT, $tag, $install_in);
}
$*ST.install_package_symbol($install_in, '&' ~ $r.name, $r);
if $install_in.WHO.exists($exp_name) {
die "A symbol $exp_name has already been exported";
}
$*ST.install_package_symbol($install_in, $exp_name, $r);
}
}
}
Expand Down

0 comments on commit 31e7121

Please sign in to comment.