Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make package block code objects sooner.
This means they are available for variable trait application to use,
thus fixing RT #125455.
  • Loading branch information
jnthn committed Jun 23, 2015
1 parent 46caea2 commit db71bf4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/Perl6/Actions.nqp
Expand Up @@ -2126,8 +2126,11 @@ Compilation unit '$file' contained the following violations:
QAST::WVal.new( :value($*PACKAGE) ),
QAST::Op.new( :op('curlexpad') )));

# Create code object and add it as the role's body block.
my $code := $*W.create_code_object($block, 'Sub', $sig);
# Finish code object and add it as the role's body block.
my $code := $*CODE_OBJECT;
$*W.attach_signature($code, $sig);
$*W.finish_code_object($code, $block, 0);
$*W.add_phasers_handling_code($code, $block);
$*W.pkg_set_role_body_block($/, $*PACKAGE, $code, $block);

# Compose before we add the role to the group, so the group sees
Expand All @@ -2144,9 +2147,11 @@ Compilation unit '$file' contained the following violations:
# Compose.
$*W.pkg_compose($*PACKAGE);

# Make a code object for the block.
$*W.create_code_object($block, 'Block',
$*W.create_signature(nqp::hash('parameter_objects', [])));
# Finish code object for the block.
my $code := $*CODE_OBJECT;
$*W.attach_signature($code, $*W.create_signature(nqp::hash('parameter_objects', [])));
$*W.finish_code_object($code, $block, 0);
$*W.add_phasers_handling_code($code, $block);
}

# check up any private attribute usage
Expand Down
1 change: 1 addition & 0 deletions src/Perl6/Grammar.nqp
Expand Up @@ -2001,6 +2001,7 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
:my $outer := $*W.cur_lexpad();
:my $*IMPLICIT := 0;
:my $*DECLARAND;
:my $*CODE_OBJECT := $*W.stub_code_object($*PKGDECL eq 'role' ?? 'Sub' !! 'Block');
:my $*IN_DECL := 'package';
:my $*HAS_SELF := '';
:my $*CURPAD;
Expand Down

0 comments on commit db71bf4

Please sign in to comment.