=begin pod :kind("Type") :subkind("role") :category("metamodel")

=TITLE role Metamodel::MROBasedMethodDispatch

=SUBTITLE Metaobject that supports resolving inherited methods

    role Metamodel::MROBasedMethodDispatch { }

I<Warning>: this role is part of the Rakudo implementation, and is not
a part of the language specification.

This role implements locating methods based on the method resolution order of
related (usually "super"/"parent") types.

=head1 Methods

=head2 method find_method

    method find_method($obj, $name, :$no_fallback, *%adverbs)

Given a method name, it returns the method object of that name which is closest
in the method resolution order (MRO). If no method can be found, it returns a
VM-specific sentinel value (typically a low-level NULL value) that can be tested
for with a test for L<definedness|/routine/defined>:

    for <upper-case  uc> {
        Str.^find_method: $^meth andthen .("foo").say
            orelse "method `$meth` not found".say
    }
    # OUTPUT:
    # method `upper-case` not found
    # FOO

If C<:no_fallback> is supplied, fallback methods are not considered.

=head2 method find_method_qualified

    method find_method_qualified($obj, $type, $name)

Given a method name and a type, returns the method from that type. This is
used in calls like

=for code :skip-test<code chunk for illustration>
self.SomeParentClass::the_method();

=head2 method can

    method can($obj, $name)

Returns the list of methods of that name the object can do.

=head2 method publish_method_cache

Defined as:

    method publish_method_cache($obj)

Walk MRO and add methods to cache, unless another method lower in the class
hierarchy "shadowed" it.


=end pod
