X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMouse.git;a=blobdiff_plain;f=lib%2FMouse%2FMeta%2FTypeConstraint.pm;h=2593b8250a3bb7bf64636b1fc0679d1f3163d9f1;hp=43a03c5f3a471e407dc8a92ba428e75c76fdf9b2;hb=de0d4152ac07ed26a928841729e97366187b2915;hpb=4c99ea954f2e8db186c9b3559579f63d26969c95 diff --git a/lib/Mouse/Meta/TypeConstraint.pm b/lib/Mouse/Meta/TypeConstraint.pm index 43a03c5..2593b82 100644 --- a/lib/Mouse/Meta/TypeConstraint.pm +++ b/lib/Mouse/Meta/TypeConstraint.pm @@ -138,10 +138,14 @@ sub check { sub coerce { my $self = shift; + my $coercion = $self->_compiled_type_coercion; + if(!$coercion){ + Carp::confess("Cannot coerce without a type coercion"); + } + return $_[0] if $self->_compiled_type_constraint->(@_); - my $coercion = $self->_compiled_type_coercion; - return $coercion ? $coercion->(@_) : $_[0]; + return $coercion->(@_); } sub get_message {