1 package # hide me from PAUSE
7 use Scalar::Util 'blessed';
15 my $class = blessed($self) || $self;
16 my $indirect = caller() =~ /^(?:next|maybe::next)$/;
17 my $level = $indirect ? 2 : 1;
19 my ($method_caller, $label, @label);
20 while ($method_caller = (caller($level++))[3]) {
21 @label = (split '::', $method_caller);
30 my $caller = join '::' => @label;
32 $method = $METHOD_CACHE{"$class|$caller|$label"} ||= do {
34 my @MRO = Class::C3::calculateMRO($class);
37 while ($current = shift @MRO) {
38 last if $caller eq $current;
43 foreach my $class (@MRO) {
44 next if (defined $Class::C3::MRO{$class} &&
45 defined $Class::C3::MRO{$class}{methods}{$label});
46 last if (defined ($found = *{$class . '::' . $label}{CODE}));
52 return $method if $indirect;
54 die "No next::method '$label' found for $self" if !$method;
59 sub can { method($_[0]) }
61 package # hide me from PAUSE
67 our $VERSION = '0.02';
69 sub method { (next::method($_[0]) || return)->(@_) }