same methods for a single role did not work
right (worked just fine with multiple roles)
- added test for this
+ * Moose::Meta::Role::Application::RoleSummation
+ - fixed the error message when trying to compose
+ a role with a role it excludes (Sartak)
* Moose::Exporter
- Catch another case where recursion caused the value
of $CALLER to be stamped on (t0m)
sub check_role_exclusions {
my ($self, $c) = @_;
- my @all_excluded_roles = $uniq->(map {
- $_->get_excluded_roles_list
- } @{$c->get_roles});
+ my %excluded_roles;
+ for my $role (@{ $c->get_roles }) {
+ my $name = $role->name;
+
+ for my $excluded ($role->get_excluded_roles_list) {
+ push @{ $excluded_roles{$excluded} }, $name;
+ }
+ }
foreach my $role (@{$c->get_roles}) {
- foreach my $excluded (@all_excluded_roles) {
- Moose->throw_error("Conflict detected: " . $role->name . " excludes role '" . $excluded . "'")
- if $role->does_role($excluded);
+ foreach my $excluded (keys %excluded_roles) {
+ next unless $role->does_role($excluded);
+
+ my @excluding = @{ $excluded_roles{$excluded} };
+ Moose->throw_error(sprintf 'Conflict detected: Role%s %s exclude%s role "%s"', (@excluding == 1 ? '' : 's'), join(', ', @excluding), (@excluding == 1 ? 's' : ''), $excluded);
}
}
- $c->add_excluded_roles(@all_excluded_roles);
+ $c->add_excluded_roles(keys %excluded_roles);
}
sub check_required_methods {
::throws_ok {
with 'Molecule::Organic', 'Molecule::Inorganic';
- } qr/Conflict detected: .+ excludes role \'Molecule::Inorganic\'/,
+ } qr/Conflict detected: Role Molecule::Organic excludes role "Molecule::Inorganic"/,
'... adding the role w/ excluded role conflict dies okay';
package My::Test3;