use Moose::Meta::TypeCoercion::Union;
-our $VERSION = '0.57';
+our $VERSION = '0.59';
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(
- name => (join ' | ' => map { $_->name } @{$options{type_constraints}}),
+ name => (join '|' => sort {$a cmp $b}
+ map { $_->name } @{$options{type_constraints}}),
parent => undef,
message => undef,
hand_optimized_type_constraint => undef,
return 0;
}
+sub create_childtype {
+ my ($self, %opts) = @_;
+ my $class = ref $self;
+ my $constraint = Moose::Meta::TypeConstraint->new(%opts, parent => $self);
+
+ # if we have a type constraint union, and no
+ # type check, this means we are just aliasing
+ # the union constraint, which means we need to
+ # handle this differently.
+ # - SL
+ if (
+ not(defined $opts{constraint})
+ && $self->has_coercion
+ ) {
+ $constraint->coercion(Moose::Meta::TypeCoercion::Union->new(
+ type_constraint => $self,
+ ));
+ }
+
+ return $constraint;
+}
+
1;
__END__
=item B<has_hand_optimized_type_constraint>
+=item B<create_childtype>
+
=back
=head1 BUGS