return unless $self->_tc_member_type_can_coerce;
- return '@_ = ($_[0], $member_tc_obj->coerce($_[1]));';
+ return '@_ = ($_[0], $member_coercion->($_[1]));';
};
sub _new_members { '$_[1]' }
return unless $self->_tc_member_type_can_coerce;
- return '@_ = ($_[0], $member_tc_obj->coerce($_[1]));';
+ return '@_ = ($_[0], $member_coercion->($_[1]));';
};
sub _new_members { '$_[1]' }
return unless $self->_tc_member_type_can_coerce;
return (
- '(' . $self->_new_members . ') = map { $member_tc_obj->coerce($_) }',
+ '(' . $self->_new_members . ') = map { $member_coercion->($_) }',
$self->_new_members . ';',
);
}
"if ($check) {",
$self->_inline_throw_error(
'"A new member value for ' . $attr_name
- . ' does not pass its type constraint because: "'
- . ' . $member_tc_obj->get_message($new_val)',
+ . ' does not pass its type constraint because: "' . ' . '
+ . 'do { local $_ = $new_val; $member_message->($new_val) }',
'data => $new_val',
) . ';',
'}',
return $env unless $member_tc;
- $env->{'$member_tc_obj'} = \($member_tc);
-
$env->{'$member_tc'} = \( $member_tc->_compiled_type_constraint );
+ $env->{'$member_coercion'} = \(
+ $member_tc->coercion->_compiled_type_coercion
+ ) if $member_tc->has_coercion;
+ $env->{'$member_message'} = \(
+ $member_tc->has_message
+ ? $member_tc->message
+ : $member_tc->_default_message
+ );
my $tc_env = $member_tc->inline_environment();
'my $iter = List::MoreUtils::natatime(2, @_);',
'@_ = ();',
'while (my ($key, $val) = $iter->()) {',
- 'push @_, $key, $member_tc_obj->coerce($val);',
+ 'push @_, $key, $member_coercion->($val);',
'}',
);
};