my $optimized_constraints = Mouse::TypeRegistry->optimized_constraints;
if (@type_constraints == 1) {
$code = $optimized_constraints->{$type_constraints[0]} ||
- sub { Scalar::Util::blessed($_) && Scalar::Util::blessed($_) eq $type_constraints[0] };
+ sub { Scalar::Util::blessed($_) && $_->isa($type_constraints[0]) };
$args{type_constraint} = $type_constraints[0];
} else {
my @code_list = map {
my $type = $_;
$optimized_constraints->{$type} ||
- sub { Scalar::Util::blessed($_) && Scalar::Util::blessed($_) eq $type }
+ sub { Scalar::Util::blessed($_) && $_->isa($type) }
} @type_constraints;
$code = sub {
for my $code (@code_list) {
my $class = $conf->{class};
Mouse::load_class($class);
_subtype(
- $name => where => sub {
- defined $_ && ref($_) eq $class;
- }
+ $name => where => sub { $_->isa($class) }
);
}