Subject: | "overwrite a locally defined method" exception thrown if used in class composed with role at compile time |
(To be honest, I'm not sure if the subject is 100% accurate; it's as close as I could get)
Perl 5.28
Moo 2.003004
MooX::TypeTiny 0.001003
Role::Tiny 2.000006
The following code,
package Common {
use Moo::Role;
has _meta => ( is => 'ro' );
}
package Cmd {
use Moo;
use Moo::Role ();
BEGIN { Moo::Role->apply_roles_to_package( __PACKAGE__, 'MyRole' ); }
use MooX::TypeTiny;
with 'Common';
}
where MyRole.pm is
package MyRole;
use Moo::Role;
has _meta => ( is => 'ro', );
1;
results in
You cannot overwrite a locally defined method (_meta) with a
reader at /[...]/lib/site_perl/5.28.0/Role/Tiny.pm line 113.
Without the use of MooX::TypeTiny it compiles with no error. If
I load MooX::TypeTiny via:
with 'Common';
require MooX::TypeTiny;
MooX::TypeTiny->import();
It also compiles with no error. The (mis-)behavior is triggered
by the following lines in MooX::TypeTiny:
16 Moo::Role->apply_roles_to_object(
17 Moo->_accessor_maker_for($target),
18 'Method::Generate::Accessor::Role::TypeTiny',
19 );
even when Method::Generate::Accessor::Role::TypeTiny is simplified to this
package Method::Generate::Accessor::Role::TypeTiny;
use Moo::Role;
1;
I'm afraid I've run out of tuits to persue this any deeper...
Thanks,
Diab