Subject: | Moo does not differentiate stubs from actual methods |
Here's an example:
perl -e '
package Interface;
use Moo::Role;
requires q{attr};
package Class;
use Moo;
with q{Interface};
has attr => ( is => q{ro} );
'
Which fails with:
Can't apply Interface to Class - missing attr at /home/book/perl5/lib/perl5/Role/Tiny.pm line 317.
OK, so I'll fix it with a stub:
perl -e '
package Interface;
use Moo::Role;
requires q{attr};
package Class;
use Moo;
with q{Interface};
sub attr; # stub
has attr => ( is => q{ro} );
'
But that fails with:
You cannot overwrite a locally defined method (attr) with a reader at /home/book/perl5/lib/perl5/Method/Generate/Accessor.pm line 30.
It should be possible to see the difference between a stub and actual code reference.