From: Dave Rolsky Date: Fri, 16 Sep 2011 14:11:05 +0000 (-0500) Subject: Fix is_subtype_of - we cannot use ->equals X-Git-Tag: 2.0300~50 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7463cac215b5bec6df3ebefae92b356a1f805fba;p=gitmo%2FMoose.git Fix is_subtype_of - we cannot use ->equals Calling $parent->equals in is_subtype_of is broken. The parent may be a union type, in which case it overrides $parent->equals will never return true. However, union types override ->is_a_type_of and ->is_subtype_of to do something sensible. Changing $parent->equals to $parent->is_a_type_of respects that overriding and gets us sane behavior. --- diff --git a/lib/Moose/Meta/TypeConstraint.pm b/lib/Moose/Meta/TypeConstraint.pm index 2b56617..e135a38 100644 --- a/lib/Moose/Meta/TypeConstraint.pm +++ b/lib/Moose/Meta/TypeConstraint.pm @@ -289,7 +289,7 @@ sub is_subtype_of { my $current = $self; while (my $parent = $current->parent) { - return 1 if $parent->equals($type); + return 1 if $parent->is_a_type_of($type); $current = $parent; }