X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMouse%2FUtil%2FTypeConstraints.pm;h=09f5077e692ccd3de92f16ade934684362169765;hb=fa9a3caafde48555c4711bcc7dee544396281600;hp=732797fb87d2a2111e88b00310ee5fe0b9fce204;hpb=7dbebb1bd235797a97c433d40c50a70628a07e3f;p=gitmo%2FMouse.git diff --git a/lib/Mouse/Util/TypeConstraints.pm b/lib/Mouse/Util/TypeConstraints.pm index 732797f..09f5077 100644 --- a/lib/Mouse/Util/TypeConstraints.pm +++ b/lib/Mouse/Util/TypeConstraints.pm @@ -90,7 +90,7 @@ my $optimized_constraints_base; sub _type { my $pkg = caller(0); my($name, %conf) = @_; - if (my $type = $TYPE{$name}) { + if ($TYPE{$name} && $TYPE_SOURCE{$name} ne $pkg) { Carp::croak "The type constraint '$name' has already been created in $TYPE_SOURCE{$name} and cannot be created again in $pkg"; }; my $constraint = $conf{where} || do { $TYPE{delete $conf{as} || 'Any' } }; @@ -102,7 +102,7 @@ sub _type { sub _subtype { my $pkg = caller(0); my($name, %conf) = @_; - if (my $type = $TYPE{$name}) { + if ($TYPE{$name} && $TYPE_SOURCE{$name} ne $pkg) { Carp::croak "The type constraint '$name' has already been created in $TYPE_SOURCE{$name} and cannot be created again in $pkg"; }; my $constraint = $conf{where} || do { $TYPE{delete $conf{as} || 'Any' } }; @@ -143,7 +143,6 @@ sub _class_type { my $pkg = caller(0); my($name, $conf) = @_; my $class = $conf->{class}; - Mouse::load_class($class); _subtype( $name => where => sub { $_->isa($class) } );