From: Fuji, Goro Date: Sat, 13 Nov 2010 14:38:30 +0000 (+0900) Subject: Fix type composition X-Git-Tag: 0.87~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f43060b65ad710abc58ab3e1f4288a71deb00ec6;p=gitmo%2FMouse.git Fix type composition --- diff --git a/lib/Mouse/Meta/TypeConstraint.pm b/lib/Mouse/Meta/TypeConstraint.pm index 15fe6e9..395ea78 100644 --- a/lib/Mouse/Meta/TypeConstraint.pm +++ b/lib/Mouse/Meta/TypeConstraint.pm @@ -261,8 +261,9 @@ sub _identity; # overload 0+ 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), ); } diff --git a/lib/Mouse/Util/TypeConstraints.pm b/lib/Mouse/Util/TypeConstraints.pm index a5220a3..2e9eaac 100644 --- a/lib/Mouse/Util/TypeConstraints.pm +++ b/lib/Mouse/Util/TypeConstraints.pm @@ -290,8 +290,9 @@ sub _find_or_create_parameterized_type{ } 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;