From: Jesse Luehrs Date: Sat, 17 Sep 2011 18:05:59 +0000 (-0500) Subject: allow overriding class and role types with equivalent types X-Git-Tag: 2.0300~31 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6f49644548;p=gitmo%2FMoose.git allow overriding class and role types with equivalent types --- diff --git a/lib/Moose/Util/TypeConstraints.pm b/lib/Moose/Util/TypeConstraints.pm index 46db335..88f1dd7 100644 --- a/lib/Moose/Util/TypeConstraints.pm +++ b/lib/Moose/Util/TypeConstraints.pm @@ -158,11 +158,13 @@ sub create_class_type_constraint { my $pkg_defined_in = scalar( caller(1) ); if (my $type = $REGISTRY->get_type_constraint($class)) { - _confess( - "The type constraint '$class' has already been created in " - . $type->_package_defined_in - . " and cannot be created again in " - . $pkg_defined_in ) + if (!($type->isa('Moose::Meta::TypeConstraint::Class') && $type->class eq $class)) { + _confess( + "The type constraint '$class' has already been created in " + . $type->_package_defined_in + . " and cannot be created again in " + . $pkg_defined_in ) + } } my %options = ( @@ -189,11 +191,13 @@ sub create_role_type_constraint { my $pkg_defined_in = scalar( caller(1) ); if (my $type = $REGISTRY->get_type_constraint($role)) { - _confess( - "The type constraint '$role' has already been created in " - . $type->_package_defined_in - . " and cannot be created again in " - . $pkg_defined_in ) + if (!($type->isa('Moose::Meta::TypeConstraint::Role') && $type->role eq $role)) { + _confess( + "The type constraint '$role' has already been created in " + . $type->_package_defined_in + . " and cannot be created again in " + . $pkg_defined_in ) + } } my %options = (