From: Yuval Kogman Date: Fri, 18 Apr 2008 15:51:40 +0000 (+0000) Subject: Allow type coercions to be declared from anon types X-Git-Tag: 0_55~216 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9c637fcaadcd5c493c1f92fa4b5111929a76bea6;p=gitmo%2FMoose.git Allow type coercions to be declared from anon types --- diff --git a/lib/Moose/Meta/TypeCoercion.pm b/lib/Moose/Meta/TypeCoercion.pm index 1412ae7..26d5420 100644 --- a/lib/Moose/Meta/TypeCoercion.pm +++ b/lib/Moose/Meta/TypeCoercion.pm @@ -43,7 +43,7 @@ sub compile_type_coercion { my @coercions; while (@coercion_map) { my ($constraint_name, $action) = splice(@coercion_map, 0, 2); - my $type_constraint = Moose::Util::TypeConstraints::find_or_parse_type_constraint($constraint_name); + my $type_constraint = ref $constraint_name ? $constraint_name : Moose::Util::TypeConstraints::find_or_parse_type_constraint($constraint_name); (defined $type_constraint) || confess "Could not find the type constraint ($constraint_name) to coerce from"; push @coercions => [