Subject: | Conflict between WithOverloading and Parameterized roles |
Setting up the requires in Parameterized doesn't work when WithOverloading is in the same class. Big long exception (code is attached):
'Moose::Meta::Role::__ANON__::SERIAL::7' requires the method 'does_X' to be implemented by 'X2' at /home/dmcbride/tmp/isas/perl5.18.2/opt/IBM/mibe/perl/lib/site_perl/5.18.2/x86_64-linux-thread-multi/Moose/Exception.pm line 38
Moose::Exception::_build_trace('Moose::Exception::RequiredMethodsNotImplementedByClass=HASH(0x35c25d8)') called at reader Moose::Exception::trace (defined at /home/dmcbride/tmp/isas/perl5.18.2/opt/IBM/mibe/perl/lib/site_perl/5.18.2/x86_64-linux-thread-multi/Moose/Exception.pm line 12) line 7
Moose::Exception::trace('Moose::Exception::RequiredMethodsNotImplementedByClass=HASH(0x35c25d8)') called at /home/dmcbride/tmp/isas/perl5.18.2/opt/IBM/mibe/perl/lib/site_perl/5.18.2/x86_64-linux-thread-multi/Moose/Exception.pm line 50
Moose::Exception::BUILD('Moose::Exception::RequiredMethodsNotImplementedByClass=HASH(0x35c25d8)', 'HASH(0x35c5e18)') called at /home/dmcbride/tmp/isas/perl5.18.2/opt/IBM/mibe/perl/lib/site_perl/5.18.2/x86_64-linux-thread-multi/Class/MOP/Method.pm line 131
Class::MOP::Method::execute('Moose::Meta::Method=HASH(0x36af0f0)', 'Moose::Exception::RequiredMethodsNotImplementedByClass=HASH(0x35c25d8)', 'HASH(0x35c5e18)') called at /home/dmcbride/tmp/isas/perl5.18.2/opt/IBM/mibe/perl/lib/site_perl/5.18.2/x86_64-linux-thread-multi/Moose/Object.pm line 59
Moose::Object::BUILDALL('Moose::Exception::RequiredMethodsNotImplementedByClass=HASH(0x35c25d8)', 'HASH(0x35c5e18)') called at /home/dmcbride/tmp/isas/perl5.18.2/opt/IBM/mibe/perl/lib/site_perl/5.18.2/x86_64-linux-thread-multi/Moose/Meta/Class.pm line 285
Moose::Meta::Class::new_object('Moose::Meta::Class=HASH(0x35d0d38)', 'HASH(0x35c5e18)') called at /home/dmcbride/tmp/isas/perl5.18.2/opt/IBM/mibe/perl/lib/site_perl/5.18.2/x86_64-linux-thread-multi/Moose/Object.pm line 30
Moose::Object::new('Moose::Exception::RequiredMethodsNotImplementedByClass', 'class', 'Moose::Meta::Class=HASH(0x35acf58)', 'role', 'MooseX::Role::Parameterized::Meta::Role::Parameterized=HASH(0x35d14d0)', 'missing_methods', 'ARRAY(0x31f33e8)') called at /home/dmcbride/tmp/isas/perl5.18.2/opt/IBM/mibe/perl/lib/site_perl/5.18.2/x86_64-linux-thread-multi/Moose/Util.pm line 54
Moose::Util::throw_exception('RequiredMethodsNotImplementedByClass', 'class', 'Moose::Meta::Class=HASH(0x35acf58)', 'role', 'MooseX::Role::Parameterized::Meta::Role::Parameterized=HASH(0x35d14d0)', 'missing_methods', 'ARRAY(0x31f33e8)') called at /home/dmcbride/tmp/isas/perl5.18.2/opt/IBM/mibe/perl/lib/site_perl/5.18.2/x86_64-linux-thread-multi/Moose/Meta/Role/Application/ToClass.pm line 110
Moose::Meta::Role::Application::ToClass::check_required_methods('Moose::Meta::Class::__ANON__::SERIAL::3=HASH(0x35c5f08)', 'MooseX::Role::Parameterized::Meta::Role::Parameterized=HASH(0x35d14d0)', 'Moose::Meta::Class=HASH(0x35acf58)') called at /home/dmcbride/tmp/isas/perl5.18.2/opt/IBM/mibe/perl/lib/site_perl/5.18.2/x86_64-linux-thread-multi/Moose/Meta/Role/Application.pm line 57
Moose::Meta::Role::Application::apply('Moose::Meta::Class::__ANON__::SERIAL::3=HASH(0x35c5f08)', 'MooseX::Role::Parameterized::Meta::Role::Parameterized=HASH(0x35d14d0)', 'Moose::Meta::Class=HASH(0x35acf58)') called at /home/dmcbride/tmp/isas/perl5.18.2/opt/IBM/mibe/perl/lib/site_perl/5.18.2/x86_64-linux-thread-multi/Moose/Meta/Role/Application/ToClass.pm line 38
Moose::Meta::Role::Application::ToClass::apply('Moose::Meta::Class::__ANON__::SERIAL::3=HASH(0x35c5f08)', 'MooseX::Role::Parameterized::Meta::Role::Parameterized=HASH(0x35d14d0)', 'Moose::Meta::Class=HASH(0x35acf58)', 'HASH(0x35c25f0)') called at /home/dmcbride/tmp/isas/perl5.18.2/opt/IBM/mibe/perl/lib/site_perl/5.18.2/x86_64-linux-thread-multi/Moose/Meta/Role.pm line 477
Moose::Meta::Role::apply('MooseX::Role::Parameterized::Meta::Role::Parameterized=HASH(0x35d14d0)', 'Moose::Meta::Class=HASH(0x35acf58)', 'type', 'Y') called at /home/dmcbride/tmp/isas/perl5.18.2/opt/IBM/mibe/perl/lib/site_perl/5.18.2/MooseX/Role/Parameterized/Meta/Role/Parameterizable.pm line 110
MooseX::Role::Parameterized::Meta::Role::Parameterizable::apply('Moose::Meta::Class::__ANON__::SERIAL::1=HASH(0x35ac400)', 'Moose::Meta::Class=HASH(0x35acf58)', 'type', 'Y') called at /home/dmcbride/tmp/isas/perl5.18.2/opt/IBM/mibe/perl/lib/site_perl/5.18.2/x86_64-linux-thread-multi/Moose/Util.pm line 169
Moose::Util::_apply_all_roles('Moose::Meta::Class=HASH(0x35acf58)', undef, 'R', 'HASH(0x34ae130)') called at /home/dmcbride/tmp/isas/perl5.18.2/opt/IBM/mibe/perl/lib/site_perl/5.18.2/x86_64-linux-thread-multi/Moose/Util.pm line 111
Moose::Util::apply_all_roles('Moose::Meta::Class=HASH(0x35acf58)', 'R', 'HASH(0x34ae130)') called at /home/dmcbride/tmp/isas/perl5.18.2/opt/IBM/mibe/perl/lib/site_perl/5.18.2/x86_64-linux-thread-multi/Moose.pm line 63
Moose::with('Moose::Meta::Class=HASH(0x35acf58)', 'R', 'HASH(0x34ae130)') called at /home/dmcbride/tmp/isas/perl5.18.2/opt/IBM/mibe/perl/lib/site_perl/5.18.2/x86_64-linux-thread-multi/Moose/Exporter.pm line 408
Moose::with('R', 'HASH(0x34ae130)') called at t.pl line 27
Note that if I change the order of the two roles, I get a different error. Removing WithOverloading from the code fixes the problem (of course it means overloading isn't going to work from within the role).
I don't know if this is a problem in WithOverloading, Parameterized, Moose, or any combination thereof, so I'm taking a stab in the dark here as to where to open this.
Subject: | t.pl |
package R;
use MooseX::Role::Parameterized;
use MooseX::Role::WithOverloading;
use 5.18.0;
parameter type =>
( isa => 'Str', required => 1 );
role {
my $p = shift;
my $t = $p->type();
requires "does_$t";
};
package X1;
use Moose;
with R => {
type => 'X'
};
sub does_X {
}
package X2;
use Moose;
with R => {
type => 'Y'
};
sub does_Y {
}
package main;
exit 0;