I've worked out how to do it, by adding a custom dispatch:<.?> method:
use Test;
class C {
method foo { 42 }
method can($meth-name) {
my $meths = callsame;
if !$meths && $meth-name eq 'bar' {
$meths = [method { 69 }, ];
self.^add_method($meth-name,
# New Ticket Created by David Warring
# Please include the string: [perl #129907]
# in the subject line of all future correspondence about this issue.
# https://rt.perl.org/Ticket/Display.html?id=129907 >
I'm adding a FALLBACK method to create method dynamically, the it receives
both '.' and