X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMouse%2FUtil%2FTypeConstraints.pm;h=61810e5a8ae23f259e0737432c87e4fd37c33354;hb=66e3df7a8d3d839b53f6fc3af8f4bad6fc27fefe;hp=bc3248940ad05438a666c5e0d18dd2a5b6c93214;hpb=ef223decd6bf1150e5219d150911404a11df072d;p=gitmo%2FMouse.git diff --git a/lib/Mouse/Util/TypeConstraints.pm b/lib/Mouse/Util/TypeConstraints.pm index bc32489..61810e5 100644 --- a/lib/Mouse/Util/TypeConstraints.pm +++ b/lib/Mouse/Util/TypeConstraints.pm @@ -4,7 +4,8 @@ use Mouse::Util; # enables strict and warnings use Mouse::Meta::TypeConstraint; use Mouse::Exporter; -use Carp (); +use Carp (); +use Scalar::Util (); Mouse::Exporter->setup_import_methods( as_is => [qw( @@ -211,7 +212,8 @@ sub role_type { return subtype $name => ( as => 'Object', optimized_as => sub { - return Mouse::Util::does_role($_[0], $role); + return Scalar::Util::blessed($_[0]) + && Mouse::Util::does_role($_[0], $role); }, role => $role, ); @@ -288,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; @@ -429,7 +432,7 @@ Mouse::Util::TypeConstraints - Type constraint system for Mouse =head1 VERSION -This document describes Mouse version 0.85 +This document describes Mouse version 0.88 =head2 SYNOPSIS