Skip to content

Commit

Permalink
allow binder lowering if type captures exist
Browse files Browse the repository at this point in the history
this happens quite often for roles, as they bind
::?CLASS and $?CLASS for their methods when they are
composed.

I saw 55 cases of binder lowering being prevented by
the existence of type captures across CORE.setting.
  • Loading branch information
timo committed Jun 21, 2015
1 parent c4ccf90 commit a927a5a
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/Perl6/Actions.nqp
Original file line number Diff line number Diff line change
Expand Up @@ -6563,7 +6563,6 @@ Compilation unit '$file' contained the following violations:
my $param_obj := @p_objs[$i];
my int $flags := nqp::getattr_i($param_obj, $Param, '$!flags');
return 0 if nqp::existskey(%info, 'sub_signature');
return 0 if nqp::existskey(%info, 'type_captures'); # XXX Support later
return 0 if %info<bind_accessor>; # XXX Support later
return 0 if %info<default_from_outer>;

Expand Down Expand Up @@ -6797,6 +6796,25 @@ Compilation unit '$file' contained the following violations:
}
}

# If there are type captures involved - most commonly $?CLASS and
# ::?CLASS - we emit a piece of code for each target that gets the
# WHAT of the given value and binds it.
#
# In theory, we could bind a local with the result of the WHAT
# operation, but I'm not convinced it's sufficiently expensive.
if %info<type_captures> {
for %info<type_captures> {
$var.push( QAST::Op.new(
:op<bind>,
QAST::Var.new( :name($_), :scope<lexical> ),
QAST::Op.new( :op<what>,
QAST::Var.new( :name($name), :scope<local> ) )
)
);
}
}


# If it's the invocant, needs to go into self also.
if %info<is_invocant> {
$var.push(QAST::Op.new(
Expand Down

0 comments on commit a927a5a

Please sign in to comment.