X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FMeta%2FTypeConstraint%2FUnion.pm;h=0ee81659dcc94141c869b168598c41db0f1aa33d;hb=c05704596921f27fba4b1148dfed3ddd0d15795e;hp=410c6223d62e0d8875e04f72aa4635abe049004e;hpb=c0841d0c2cb7adbe152c01f63fa6e830ee4fbe71;p=gitmo%2FMoose.git diff --git a/lib/Moose/Meta/TypeConstraint/Union.pm b/lib/Moose/Meta/TypeConstraint/Union.pm index 410c622..0ee8165 100644 --- a/lib/Moose/Meta/TypeConstraint/Union.pm +++ b/lib/Moose/Meta/TypeConstraint/Union.pm @@ -29,7 +29,7 @@ sub new { %options, ); - $self->_set_constraint(sub { $self->check($_[0]) }); + $self->_set_constraint( $self->_compiled_type_constraint ); return $self; } @@ -131,14 +131,13 @@ sub equals { sub parent { my $self = shift; - my @tcs = @{ $self->type_constraints }; + my ($first, @rest) = @{ $self->type_constraints }; - my $deepest - = ( sort { $a->_ancestor_count <=> $b->_ancestor_count } @tcs )[-1]; - - for my $parent ( $deepest->_collect_all_parents ) { - return $parent if all { $_->is_a_type_of($parent) } @tcs; + for my $parent ( $first->_collect_all_parents ) { + return $parent if all { $_->is_a_type_of($parent) } @rest; } + + return; } sub validate {