From: Dave Rolsky Date: Sun, 10 Apr 2011 16:40:18 +0000 (-0500) Subject: Inlining parameterized type seems to work, but needs more explicit tests X-Git-Tag: 2.0100~81 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b612a613c907b32474fd57a2879fe30d3a799317;p=gitmo%2FMoose.git Inlining parameterized type seems to work, but needs more explicit tests --- diff --git a/lib/Moose/Meta/TypeConstraint/Parameterizable.pm b/lib/Moose/Meta/TypeConstraint/Parameterizable.pm index 1e050f3..6f82a34 100644 --- a/lib/Moose/Meta/TypeConstraint/Parameterizable.pm +++ b/lib/Moose/Meta/TypeConstraint/Parameterizable.pm @@ -43,6 +43,14 @@ sub _can_coerce_constraint_from { }; } +sub generate_inline_for { + my ($self, $type, $val) = @_; + + return unless $self->has_inline_generator; + + return $self->inline_generator->( $type, $val ); +} + sub _parse_type_parameter { my ($self, $type_parameter) = @_; return Moose::Util::TypeConstraints::find_or_create_isa_type_constraint($type_parameter); diff --git a/lib/Moose/Meta/TypeConstraint/Parameterized.pm b/lib/Moose/Meta/TypeConstraint/Parameterized.pm index 70f0828..369599d 100644 --- a/lib/Moose/Meta/TypeConstraint/Parameterized.pm +++ b/lib/Moose/Meta/TypeConstraint/Parameterized.pm @@ -66,18 +66,19 @@ sub compile_type_constraint { sub has_inlined_type_constraint { my $self = shift; - return $self->has_parameterized_from - && $self->has_parameterized_from->has_inline_generator; + return + $self->has_parameterized_from + && $self->parameterized_from->has_inline_generator + && $self->type_parameter->has_inlined_type_constraint; + } sub _inline_check { my $self = shift; - return - unless $self->has_parameterized_from - && $self->has_parameterized_from->has_inline_generator; + return unless $self->has_inlined_type_constraint; - return $self->parameterized_from->generate_inline_for( $self->type, @_ ); + return $self->parameterized_from->generate_inline_for( $self->type_parameter, @_ ); } sub create_child_type {