if something is already matching the type constraint, don't coerce it
Hans Dieter Pearcey [Fri, 24 Apr 2009 20:05:33 +0000 (16:05 -0400)]
lib/Moose/Meta/TypeConstraint.pm

index 1671d07..559ef20 100644 (file)
@@ -82,6 +82,8 @@ sub coerce {
         Moose->throw_error("Cannot coerce without a type coercion");
     }
 
+    return $_[0] if $self->check($_[0]);
+
     return $coercion->coerce(@_);
 }