role Metamodel::MROBasedMethodDispatch { }

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.

Methods§

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 definedness:

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 :no_fallback is supplied, fallback methods are not considered.

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

self.SomeParentClass::the_method();

method can§

method can($obj$name)

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

method publish_method_cache§

method publish_method_cache($obj)

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