my $attr_name = quotemeta( $attr->name );
- qq{\$type_constraint->($value) || } . $self->_inline_throw_error(qq{"Attribute ($attr_name) does not pass the type constraint because: " . \$type_constraint_obj->get_message($value)}, "data => $value") . ";";
+ my $tc = $attr->type_constraint;
+ my $check = $tc->has_hand_optimized_inline_type_constraint
+ ? $tc->inline_check_of($value, '$type_constraint')
+ : qq{\$type_constraint->($value)};
+
+ qq{$check || } . $self->_inline_throw_error(qq{"Attribute ($attr_name) does not pass the type constraint because: " . \$type_constraint_obj->get_message($value)}, "data => $value") . ";";
}
sub _inline_check_coercion {
my ($self, $value_var, $constraint_var) = @_;
$constraint_var ||= '$constraint';
$value_var ||= '$_';
- if ($self->has_hand_optimized_type_constraint) {
+ if ($self->has_hand_optimized_inline_type_constraint) {
return 'do { local @_ = ('
. $value_var
. ');'