From: Jesse Luehrs Date: Thu, 19 May 2011 14:56:39 +0000 (-0500) Subject: allow inlining if the type has been subsequently defined X-Git-Tag: v0.27~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMooseX-Types.git;a=commitdiff_plain;h=c15335068eb0937d46e85ef57af110dc64257326 allow inlining if the type has been subsequently defined --- diff --git a/lib/MooseX/Types/UndefinedType.pm b/lib/MooseX/Types/UndefinedType.pm index e4ed59d..97e4031 100644 --- a/lib/MooseX/Types/UndefinedType.pm +++ b/lib/MooseX/Types/UndefinedType.pm @@ -42,14 +42,6 @@ sub name { return $_[0]->{name}; } -=head2 can_be_inlined - -Always returns false. Needed for compatibility with Moose 2.0100+. - -=cut - -sub can_be_inlined { 0 } - =head2 __autovivify Try to see if the type constraint has yet been defined and if so create it. @@ -68,6 +60,22 @@ sub __autovivify { } } +=head2 can_be_inlined + +Make sure that if a type hasn't been defined yet when Moose wants to inline it, +we don't allow inlining. + +=cut + +sub can_be_inlined { + my $self = shift; + if(my $type_constraint = $self->__autovivify) { + return $type_constraint->can_be_inlined; + } else { + return; + } +} + =head2 AUTOLOAD Try to autovivify and delegate