nextcan#

The mro::_nextcan primitive that underpins next::method, next::can, and maybe::next::method.

Synopsis#

my $cv = mro::_nextcan($self, 0); # returns CV ref or undef my $cv = mro::_nextcan($self, 1); # croaks if no method found

Called with the invocant and a boolean $throw_if_not_found. Looks at the currently executing method, walks the C3 linearization of $self’s class past that method’s defining package, and returns the next implementation of the same method name as a CV reference.

When nothing matches, returns undef if the flag is 0 or croaks with No next::method found if the flag is 1. Callers from outside a method context croak with next::method/next::can/maybe::next::method must be used in method context.

You rarely call this directly. Reach for next::method, next::can, or maybe::next::method instead — they package the common usage patterns around this primitive.