Skip to content

Commit

Permalink
Fix cases where we try calling methods on BOOTCode
Browse files Browse the repository at this point in the history
Triggered by `role A { }; A.new ~~ A:D` code. Thanks @jdv for finding
this error!
  • Loading branch information
vrurg committed Jun 5, 2022
1 parent 5d46c27 commit 4130846
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Perl6/Optimizer.nqp
Expand Up @@ -1408,6 +1408,7 @@ my class Operand {
for ['new', 'bless'] -> $constructor {
if nqp::defined(my $meth := nqp::tryfindmethod($type, $constructor)) {
for $!optimizer.routine_candidates($meth) -> $cand {
next unless nqp::can($cand, 'package');
my $cand-pkg := $cand.package;
my $cand-ok := 0;
for @ok-types -> $ok-type {
Expand Down Expand Up @@ -4544,7 +4545,7 @@ class Perl6::Optimizer {
self.routine_candidates($wrapper, @candidates);
}
}
elsif $routine.is_dispatcher {
elsif nqp::can($routine, 'is_dispatcher') && $routine.is_dispatcher {
my @dispatchees := nqp::istype($routine, NQPRoutine)
?? nqp::getattr($routine, NQPRoutine, '$!dispatchees')
!! nqp::getattr($routine, $!symbols.Routine, '@!dispatchees');
Expand Down

0 comments on commit 4130846

Please sign in to comment.