X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FMeta%2FTypeConstraint%2FParameterizable.pm;h=b07834e9439de13ee7084ca3c79215f6bd844612;hb=aead17e74252e3884f9f8e39912ca98fdf4b4dd5;hp=15d3f1128360230f8018d08c8dc7eb706588815f;hpb=a6b7b0ac50b3696b2fe346a0aa12f97da6cf4502;p=gitmo%2FMoose.git diff --git a/lib/Moose/Meta/TypeConstraint/Parameterizable.pm b/lib/Moose/Meta/TypeConstraint/Parameterizable.pm index 15d3f11..b07834e 100644 --- a/lib/Moose/Meta/TypeConstraint/Parameterizable.pm +++ b/lib/Moose/Meta/TypeConstraint/Parameterizable.pm @@ -4,7 +4,7 @@ use strict; use warnings; use metaclass; -our $VERSION = '0.57'; +our $VERSION = '0.62'; $VERSION = eval $VERSION; our $AUTHORITY = 'cpan:STEVAN'; @@ -51,6 +51,16 @@ sub parameterize { my ($self, $type_parameter) = @_; my $contained_tc = $self->_parse_type_parameter($type_parameter); + + ## The type parameter should be a subtype of the parent's type parameter + ## if there is one. + + if(my $parent = $self->parent) { + if($parent->can('type_parameter')) { + $contained_tc->is_a_type_of($parent->type_parameter) + || Moose->throw_error("$type_parameter is not a subtype of ".$parent->type_parameter); + } + } if ( $contained_tc->isa('Moose::Meta::TypeConstraint') ) { my $tc_name = $self->name . '[' . $contained_tc->name . ']';