Subject: | Applying metarole via Moose::Util::MetaRole clobbers method modifiers. |
Which is to say, if you have some role that implements method
modifiers, and you apply some metarole to that role via
Moose::Util::MetaRole, the role will appear to have lost its method
modifiers when later applied to a class (or role).
===
{ package SOME_ROLE;
use Moose::Role;
sub some_method { 'SOME_METHOD' }
around some_method => sub { 'SOME_METHOD_WITH_MODIFIER' };
}
{ package SOME_CLASS;
use Moose;
with 'SOME_ROLE';
}
say SOME_CLASS->new->some_method; # "SOME_METHOD_WITH_MODIFIER"
{ package SOME_METAROLE;
use Moose::Role;
}
Moose::Util::MetaRole::apply_metaroles(
for => 'SOME_ROLE',
role_metaroles => {role => [qw(SOME_METAROLE)]},
);
{ package SOME_OTHER_CLASS;
use Moose;
with 'SOME_ROLE';
}
say SOME_OTHER_CLASS->new->some_method; # "SOME_METHOD"
===
I assume this is a bug since the behavior's not documented (that I
could find), but I'm not sure. Also I'm not sure whether
Moose::Util::MetaRole is the faulty layer.
Thanks, guys.
===
Moose 2.0007
Perl 5.12.1 (Strawberry)
Windows 7