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
Roles can't use stub methods to indicate "must implement" methods: calls to such methods always ambiguous #3795
Comments
From jepeway@blasted-heath.comTrying to tell doers of a role that they are expected to implement a method (a là Java interfaces) doesn’t seem to work. This role A { multi method a(Int $i) {...}; multi method a(Str $s) {...}; }; class B does A { multi method a(Int $i){0}; multi method a(Str $s) {"a"}; } ; B.new.a(0).say yields: Ambiguous call to 'a'; these signatures all match: Both TimToady and timotimo suspect this to be a bug. See http://irclog.perlgeek.de/perl6/2015-04-22#i_10480886 for their discussion. Chris. |
From @autarchOn Sat Apr 25 16:25:08 2015, jepeway@blasted-heath.com wrote:
I'd expect this to work even if the role's method wasn't a stub, as I'd expect class methods to always shadow a role method of the same name+signature. However, rakudo gives the same error regardless of whether the role method is a stub or not. |
The RT System itself - Status changed from 'new' to 'open' |
From @autarchOn Sat Apr 25 16:25:08 2015, jepeway@blasted-heath.com wrote:
I'd also note that contrary to the ticket subject, this _does_ work as expected for non-multis. A stub (non-multi) method in the role forces the consuming class to implement the method. |
From @jnthnOn Sun Nov 15 10:29:36 2015, autarch wrote:
Roles in multis are now handled by considering their signature equ, both for requirements and composition. Tests in S14-roles/composition.t. |
@jnthn - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#124393 (status was 'resolved')
Searchable as RT124393$
The text was updated successfully, but these errors were encountered: