I've been thinking more about this bug:
https://rt.cpan.org/Ticket/Display.html?id=45591
#!/usr/bin/env perl
package My::Role::Foo;
use Moose::Role;
sub foo { 'foo' }
package My::Class;
use Moose;
with 'My::Role::Foo' => { excludes => ['foo'] };
print My::Class->foo;
The error message is:
Can't locate object method "foo" via package "My::Class" at role.pl line 12.
The problem that since My::Class->meta->does('My::Role::Foo'), there's a
promise that it will provide the &foo method. However, the failure happens at
runtime, not at composition time. I'm expecting a composition-time error
message like this:
My::Role::Foo' requires the method 'foo' to be implemented by 'My::Class' at
...
I think I misdiagnosed the fix. I think a better fix for this is ensuring
every method a role provides is added to the 'requires' list. Just added
"requires qw(foo);" to the above code makes it work as expected. However, I
can't quite figure out how to make this work. I've tried several approaches
(most interesting has been hooking into 'with'), but
&Moose::Meta::Role::Application::apply has some interesting sequencing issues
which was causing a couple of test failures.
Thoughts?
Cheers,
Ovid
--
Buy the book - http://www.oreilly.com/catalog/perlhks/
Tech blog - http://use.perl.org/~Ovid/journal/
Twitter - http://twitter.com/OvidPerl
Official Perl 6 Wiki - http://www.perlfoundation.org/perl6