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.
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;
}