-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to use Multi Methods in Roles #36
Comments
From [email protected] on 2017-12-09 20:14:33 Example in code:package My::Role; use Moo::Role; multi method process (ArrayRef $x) { say "here" } package My::Consumer; use Moo; PACKAGE->process( [] ); # blows up here: Arguments to My::Role::process did not match any known signature for multi sub On Sat Dec 09 15:07:52 2017, RLANG wrote:
|
1 similar comment
From [email protected] on 2017-12-09 20:14:33 Example in code:package My::Role; use Moo::Role; multi method process (ArrayRef $x) { say "here" } package My::Consumer; use Moo; PACKAGE->process( [] ); # blows up here: Arguments to My::Role::process did not match any known signature for multi sub On Sat Dec 09 15:07:52 2017, RLANG wrote:
|
From [email protected] on 2018-06-26 10:01:15 To be honest, I've never really given the concept much thought, but multi methods in roles could be cool. Different roles might even define different signatures for the same method and the class could compose both. I do think this should be supported. |
Migrated from rt.cpan.org #123849 (status was 'open')
Requestors:
From [email protected] on 2017-12-09 20:07:52
:
Hi there-
It appears that multi subs/methods don't work properly when being composed in roles (Moo::Role).
I did a little digging, and it seems that rather than methods being registered under the package name of a role's consumer, they are registered under the package name of the role itself. So when it comes time to look up a method in the dispatch table, we're looking in the wrong package name, and get this error:
"did not match any known signature for multi sub"
I'm not especially familiar with how Moo::Role works behind the scenes, and so maybe this is unfixable, or undesired. But it seems that if it were fixable, maybe Kavorka::Multi::__gather_candidates would be the place to do it...?
Do you have any thoughts on this?
(Big fan of Kavorka - thank you!)
Ryan Lang
The text was updated successfully, but these errors were encountered: