sub _unite { # overload infix:<|>
my($lhs, $rhs) = @_;
require Mouse::Util::TypeConstraints;
- return Mouse::Util::TypeConstraints::find_or_parse_type_constraint(
- " $lhs | $rhs",
+ return Mouse::Util::TypeConstraints::_find_or_create_union_type(
+ $lhs,
+ Mouse::Util::TypeConstraints::find_or_create_isa_type_constraint($rhs),
);
}
}
sub _find_or_create_union_type{
- return if grep{ not defined } @_;
- my @types = sort map{ $_->{type_constraints} ? @{$_->{type_constraints}} : $_ } @_;
+ return if grep{ not defined } @_; # all things must be defined
+ my @types = sort
+ map{ $_->{type_constraints} ? @{$_->{type_constraints}} : $_ } @_;
my $name = join '|', @types;