X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FUtil.pm;h=469e2814fcab8aa37a4752eaa88be72bb11665b6;hb=ff2b7a57bf3ab01b13e36bb84faab23ad8504c85;hp=11281114c5c25cdb042861374b93e161541a0164;hpb=2c739d1aa02657fcc42afa4b737d2e207d29567e;p=gitmo%2FMoose.git diff --git a/lib/Moose/Util.pm b/lib/Moose/Util.pm index 1128111..469e281 100644 --- a/lib/Moose/Util.pm +++ b/lib/Moose/Util.pm @@ -96,7 +96,18 @@ sub _apply_all_roles { Moose->throw_error("Must specify at least one role to apply to $applicant"); } - my $roles = Data::OptList::mkopt( [@_] ); + # If @_ contains role meta objects, mkopt will think that they're values, + # because they're references. In other words (roleobj1, roleobj2, + # roleobj3) will become [ [ roleobj1, roleobj2 ], [ roleobj3, undef ] ] + # -- this is no good. We'll preprocess @_ first to eliminate the potential + # bug. + # -- rjbs, 2011-04-08 + my $roles = Data::OptList::mkopt( [@_], { + moniker => 'role', + name_test => sub { + ! ref $_[0] or blessed($_[0]) && $_[0]->isa('Moose::Meta::Role') + } + }); my @role_metas; foreach my $role (@$roles) {