Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix install_method to look at scope consistently.
  • Loading branch information
jnthn committed Jul 9, 2014
1 parent 95f540d commit 7b27642
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/Perl6/Actions.nqp
Expand Up @@ -3047,8 +3047,6 @@ class Perl6::Actions is HLL::Actions does STDActions {

# Installs a method into the various places it needs to go.
sub install_method($/, $name, $scope, $code, $outer, :$private) {
# Ensure that current package supports methods, and if so
# add the method.
my $meta_meth;
if $private {
if $*MULTINESS { $/.CURSOR.panic("Private multi-methods are not supported"); }
Expand All @@ -3058,6 +3056,8 @@ class Perl6::Actions is HLL::Actions does STDActions {
$meta_meth := $*MULTINESS eq 'multi' ?? 'add_multi_method' !! 'add_method';
}
if $scope eq '' || $scope eq 'has' {
# Ensure that current package supports methods, and if so
# add the method.
if nqp::can($*PACKAGE.HOW, $meta_meth) {
$*W.pkg_add_method($/, $*PACKAGE, $meta_meth, $name, $code);
}
Expand All @@ -3068,12 +3068,10 @@ class Perl6::Actions is HLL::Actions does STDActions {
($*PKGDECL || "mainline") ~ " (did you mean 'my $*METHODTYPE $name'?)\n");
}
}

# May also need it in lexpad and/or package.
if $*SCOPE eq 'my' {
elsif $scope eq 'my' {
$*W.install_lexical_symbol($outer, '&' ~ $name, $code, :clone(1));
}
elsif $*SCOPE eq 'our' {
elsif $scope eq 'our' {
$*W.install_lexical_symbol($outer, '&' ~ $name, $code, :clone(1));
$*W.install_package_symbol($*PACKAGE, '&' ~ $name, $code);
}
Expand Down

0 comments on commit 7b27642

Please sign in to comment.