Implement 'does' attribute in has()
[gitmo/Mouse.git] / lib / Mouse / Util / TypeConstraints.pm
index 85b5698..c84c75c 100644 (file)
@@ -303,9 +303,9 @@ sub _find_or_create_parameterized_type{
     }
 }
 sub _find_or_create_union_type{
-    my @types = map{ $_->{type_constraints} ? @{$_->{type_constraints}} : $_ } @_;
+    my @types = sort{ $a cmp $b } map{ $_->{type_constraints} ? @{$_->{type_constraints}} : $_ } @_;
 
-    my $name = join '|', map{ $_->name } @types;
+    my $name = join '|', @types;
 
     $TYPE{$name} ||= do{
         return Mouse::Meta::TypeConstraint->new(
@@ -398,7 +398,7 @@ sub find_or_parse_type_constraint {
 }
 
 sub find_or_create_does_type_constraint{
-    my $type = find_or_parse_type_constriant(@_) || role_type(@_);
+    my $type = find_or_parse_type_constraint(@_) || role_type(@_);
 
     if($type->{type} && $type->{type} ne 'Role'){
         Carp::cluck("$type is not a role type");