* Moose::Manual::Attributes
- Clarify "is", include discussion of "bare". (Sartak)
+ * Moose::Meta::Role::Method::Conflicting
+ * Moose::Meta::Role::Application::ToClass
+ - For the first set of roles involved in a conflict, report all
+ unresolved method conflicts, not just the first method. Fixes #47210
+ reported by Ovid. (Sartak)
+
0.88 Fri Jul 24, 2009
* Moose::Manual::Contributing
- Re-write the Moose::Manual::Contributing document to reflect
if (@conflicts) {
my $conflict = $conflicts[0];
- my $roles = Moose::Util::english_list( map { q{'} . $_ . q{'} } @{ $conflict->roles } );
-
- $error
- .= "Due to a method name conflict in roles "
- . $roles
- . ", the method '"
- . $conflict->name
- . "' must be implemented or excluded by '"
- . $class->name
- . q{'};
+ my $roles = $conflict->roles_as_english_list;
+
+ my @same_role_conflicts = grep { $_->roles_as_english_list eq $roles } @conflicts;
+
+ if (@same_role_conflicts == 1) {
+ $error
+ .= "Due to a method name conflict in roles "
+ . $roles
+ . ", the method '"
+ . $conflict->name
+ . "' must be implemented or excluded by '"
+ . $class->name
+ . q{'};
+ }
+ else {
+ my $methods
+ = Moose::Util::english_list( map { q{'} . $_->name . q{'} } @same_role_conflicts );
+
+ $error
+ .= "Due to method name conflicts in roles "
+ . $roles
+ . ", the methods "
+ . $methods
+ . " must be implemented or excluded by '"
+ . $class->name
+ . q{'};
+ }
}
elsif (@missing) {
my $noun = @missing == 1 ? 'method' : 'methods';
use strict;
use warnings;
+use Moose::Util;
+
use base qw(Moose::Meta::Role::Method::Required);
our $VERSION = '0.88';
required => 1,
));
+sub roles_as_english_list {
+ my $self = shift;
+ Moose::Util::english_list( map { q{'} . $_ . q{'} } @{ $self->roles } );
+}
+
1;
__END__
Returns the roles that generated this conflicting method, as provided to the
constructor.
+=item B<< $method->roles_as_english_list >>
+
+Returns the roles that generated this conflicting method as an English list.
+
=back
=head1 BUGS
--- /dev/null
+#!/usr/bin/perl
+use strict;
+use warnings;
+
+use Test::More tests => 2;
+use Test::Exception;
+
+{
+ package Bomb;
+ use Moose::Role;
+
+ sub fuse { }
+ sub explode { }
+
+ package Spouse;
+ use Moose::Role;
+
+ sub fuse { }
+ sub explode { }
+
+ package Caninish;
+ use Moose::Role;
+
+ sub bark { }
+
+ package Treeve;
+ use Moose::Role;
+
+ sub bark { }
+}
+
+package PracticalJoke;
+use Moose;
+
+::throws_ok {
+ with 'Bomb', 'Spouse';
+} qr/Due to method name conflicts in roles 'Bomb' and 'Spouse', the methods 'explode' and 'fuse' must be implemented or excluded by 'PracticalJoke'/;
+
+::throws_ok {
+ with (
+ 'Bomb', 'Spouse',
+ 'Caninish', 'Treeve',
+ );
+} qr/Due to method name conflicts in roles 'Bomb' and 'Spouse', the methods 'explode' and 'fuse' must be implemented or excluded by 'PracticalJoke'/;
+