From: Dave Rolsky Date: Wed, 2 Nov 2011 17:00:07 +0000 (-0500) Subject: Fix docs on inlining to reflect reality X-Git-Tag: 2.0400~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6054adafab65254735afde889d03384b0146358a;p=gitmo%2FMoose.git Fix docs on inlining to reflect reality We use the ->parent->_inline_check approach in our code --- diff --git a/lib/Moose/Util/TypeConstraints.pm b/lib/Moose/Util/TypeConstraints.pm index fb657ca..e713562 100644 --- a/lib/Moose/Util/TypeConstraints.pm +++ b/lib/Moose/Util/TypeConstraints.pm @@ -1116,15 +1116,9 @@ The subroutine should return a code string suitable for inlining. You can assume that the check will be wrapped in parentheses when it is inlined. The inlined code should include any checks that your type's parent types -do. For example, the C type's inlining sub looks like this: - - sub { - 'defined(' . $_[1] . ')' - . ' && !ref(' . $_[1] . ')' - } - -Note that it checks if the variable is defined, since it is a subtype of -the C type. However, to avoid repeating code, this can be optimized as: +do. If your parent type constraint defines its own inlning, you can simply use +that to avoid repeating code. For example, here is the inlining code for the +C type, which is a subtype of C: sub { $_[0]->parent()->_inline_check($_[1])