X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMooseX%2FMeta%2FTypeConstraint%2FStructured.pm;h=10bb30a136ad70d98455d5deffd0b640f0bf56b9;hb=67a8bc0491edda720c7450433ccdf3cb07edb6ff;hp=eea8d51dcfe7ecf12bc0f8f1beee6d281cebf203;hpb=a30fa8914f1b06d293d2cc743bd75c2de3e157f4;p=gitmo%2FMooseX-Types-Structured.git diff --git a/lib/MooseX/Meta/TypeConstraint/Structured.pm b/lib/MooseX/Meta/TypeConstraint/Structured.pm index eea8d51..10bb30a 100644 --- a/lib/MooseX/Meta/TypeConstraint/Structured.pm +++ b/lib/MooseX/Meta/TypeConstraint/Structured.pm @@ -71,13 +71,18 @@ Given a ref of type constraints, create a structured type. =cut sub parameterize { - my ($self, @type_constraints) = @_; + my ($self, @type_constraints) = @_; my $name = $self->name .'['. join(',', map {"$_"} @type_constraints) .']'; + return __PACKAGE__->new( name => $name, parent => $self, type_constraints => \@type_constraints, - constraint_generator => $self->constraint_generator, + constraint_generator => $self->constraint_generator || sub { + my $tc = shift @_; + my $merged_tc = [@$tc, @{$self->parent->type_constraints}]; + $self->constraint->($merged_tc, @_); + }, ); }