All non-parameterized types now have inlining code
[gitmo/Moose.git] / lib / Moose / Meta / TypeConstraint.pm
index 0c35333..c783a08 100644 (file)
@@ -43,6 +43,11 @@ __PACKAGE__->meta->add_attribute('hand_optimized_type_constraint' => (
     predicate => 'has_hand_optimized_type_constraint',
 ));
 
+__PACKAGE__->meta->add_attribute('inlined' => (
+    accessor  => 'inlined',
+    predicate => 'has_inlined_type_constraint',
+));
+
 sub parents {
     my $self;
     $self->parent;
@@ -122,6 +127,15 @@ sub validate {
     }
 }
 
+sub _inline_check {
+    my $self = shift;
+
+    die 'Cannot inline a type constraint check for ' . $self->name
+        unless $self->has_inlined_type_constraint;
+
+    return $self->inlined()->(@_);
+}
+
 sub assert_valid {
     my ($self, $value) = @_;