X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMouse%2FTypeRegistry.pm;h=c722ec1ba43f5eb0812c4ea9aeeaf6c89816f0fb;hb=2b9094e8e533f1635eae1481eef711828f521508;hp=a37ce3b88c04b3d366a7a990e77f9716d72cac47;hpb=adebd0a83f0b7b52be8834444b40eedd0ddc2d66;p=gitmo%2FMouse.git diff --git a/lib/Mouse/TypeRegistry.pm b/lib/Mouse/TypeRegistry.pm index a37ce3b..c722ec1 100644 --- a/lib/Mouse/TypeRegistry.pm +++ b/lib/Mouse/TypeRegistry.pm @@ -139,21 +139,18 @@ sub _role_type { } sub typecast_constraints { - my($class, $pkg, $type_constraint, $types, $value) = @_; - my $optimized_constraints = optimized_constraints(); - - for my $type (ref($types) eq 'ARRAY' ? @{ $types } : ( $types )) { - next unless $COERCE->{$type}; + my($class, $pkg, $type, $value) = @_; + return $value unless $COERCE->{$type}; - for my $coerce_type (keys %{ $COERCE->{$type} }) { + my $optimized_constraints = optimized_constraints(); + for my $coerce_type (keys %{ $COERCE->{$type} }) { + local $_ = $value; + if ($optimized_constraints->{$coerce_type}->()) { local $_ = $value; - if ($optimized_constraints->{$coerce_type}->()) { - local $_ = $value; - local $_ = $COERCE->{$type}->{$coerce_type}->(); - return $_ if $type_constraint->(); - } + return $COERCE->{$type}->{$coerce_type}->(); } } + return $value; }