AnyIterator uses two classes to implement type-erasure:
_AnyIteratorBoxBase (which implements the
Iterator Protocol) and
_AnyIteratorBox(which inherits from
A for example,
AnySequence uses only
_AnySequenceBox(which does not implement the
Sequence Protocol, but simply repeats all its methods and properties, naming them with underscores.
Is there a reasonable explanation for this? Or is it an attempt to avoid some bug?
P.S. This question was prompted by a compiler bug that when trying to override the generic method inherited from the
_AnyMyTypeBoxBase class inside the
Declaration '...' cannot override more than one superclass declaration