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 {
}
}
- if(predicate_calls(attr, "should_coerce")){
+ if(predicate_calls(attr, "should_coerce") && predicate_calls(tc, "has_coercion")){
flags |= MOUSEf_ATTR_SHOULD_COERCE;
}