Stuff with the Perl Foundation. A couple of patches in the Perl core. A few CPAN modules. That about sums it up.
package My::Can;
use strict;
use warnings;
use Sub::Identify 'stash_name';
use base 'Exporter';
our @EXPORT = qw(CAN can);
sub CAN {
my ( $proto, $method ) = @_;
$proto->SUPER::can($method);
}
sub can {
my ( $proto, $method ) = @_;
return if '_' eq substr $method, 0, 1; # season to taste
my $coderef = $proto->SUPER::can($method) or return;
my $source_package = stash_name($coderef) or return;
return $coderef if $proto->isa($source_package);
}
1;
Update:: smylers just pointed out the bug. Do you see it? (Yes, this can fail with traits and mixins if they're not implemented carefully, but that's not the obvious issue that smylers pointed out).
Bugspotting (Score:1)
I assume you mean the fact that
SUPERrelies on the compile-time package that a function is in.Re: (Score:2)
Um, er, uh. No. But now that you mention it, my code is giving me pause. I'll have to look at my tests again. It passes them and I checked that. Now I'm a wee bit confused as to how my tests passed.