Fix Union->parent to return the nearest common ancestor
[gitmo/Moose.git] / lib / Moose / Meta / TypeConstraint.pm
index e135a38..f5dd147 100644 (file)
@@ -289,7 +289,7 @@ sub is_subtype_of {
     my $current = $self;
 
     while (my $parent = $current->parent) {
-        return 1 if $parent->is_a_type_of($type);
+        return 1 if $parent->equals($type);
         $current = $parent;
     }
 
@@ -420,6 +420,11 @@ sub _collect_all_parents {
     return @parents;
 }
 
+sub _ancestor_count {
+    my $self = shift;
+    return scalar $self->_collect_all_parents;
+}
+
 sub create_child_type {
     my ($self, %opts) = @_;
     my $class = ref $self;