delete $spec{index};
$spec{is} = 'ro' if $spec{is} eq 'lazy' or $spec{is} eq 'rwp';
delete $spec{asserter};
+ my $coerce = $spec{coerce};
if (my $isa = $spec{isa}) {
my $tc = $spec{isa} = do {
if (my $mapped = $TYPE_MAP{$isa}) {
- $mapped->();
+ my $type = $mapped->();
+ $coerce ? $type->create_child_type(name => $type->name) : $type;
} else {
Moose::Meta::TypeConstraint->new(
constraint => sub { eval { &$isa; 1 } }
);
}
};
- if (my $coerce = $spec{coerce}) {
+ if ($coerce) {
$tc->coercion(Moose::Meta::TypeCoercion->new)
->_compiled_type_coercion($coerce);
$spec{coerce} = 1;
}
- } elsif (my $coerce = $spec{coerce}) {
+ } elsif ($coerce) {
my $attr = perlstring($name);
my $tc = Moose::Meta::TypeConstraint->new(
constraint => sub { die "This is not going to work" },