From: Hans Dieter Pearcey Date: Fri, 24 Apr 2009 20:05:33 +0000 (-0400) Subject: if something is already matching the type constraint, don't coerce it X-Git-Tag: 0.76~17 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=886179b3451716d1e87a393ce43536e6b3c21e36;p=gitmo%2FMoose.git if something is already matching the type constraint, don't coerce it --- diff --git a/lib/Moose/Meta/TypeConstraint.pm b/lib/Moose/Meta/TypeConstraint.pm index 1671d07..559ef20 100644 --- a/lib/Moose/Meta/TypeConstraint.pm +++ b/lib/Moose/Meta/TypeConstraint.pm @@ -82,6 +82,8 @@ sub coerce { Moose->throw_error("Cannot coerce without a type coercion"); } + return $_[0] if $self->check($_[0]); + return $coercion->coerce(@_); }