removed some debug stuff
[gitmo/Moose.git] / lib / Moose / Meta / TypeConstraint / Union.pm
index 77a6917..c9d3f42 100644 (file)
@@ -100,6 +100,28 @@ sub is_subtype_of {
     return 0;
 }
 
+sub create_childtype {
+    my ($self, %opts) = @_;
+    my $class = ref $self;
+    my $constraint = Moose::Meta::TypeConstraint->new(%opts, parent => $self);
+    
+    # if we have a type constraint union, and no
+    # type check, this means we are just aliasing
+    # the union constraint, which means we need to
+    # handle this differently.
+    # - SL
+    if (
+            not(defined $opts{constraint})
+            && $self->has_coercion
+    ) {
+        $constraint->coercion(Moose::Meta::TypeCoercion::Union->new(
+            type_constraint => $self,
+        ));
+    }
+    
+    return $constraint;
+}
+
 1;
 
 __END__
@@ -182,6 +204,8 @@ anyway. They are here for completeness.
 
 =item B<has_hand_optimized_type_constraint>
 
+=item B<create_childtype>
+
 =back
 
 =head1 BUGS