[swift-evolution] [Proposal] More Powerful Constraints for Associated Types

Douglas Gregor dgregor at apple.com
Tue Apr 26 08:53:47 CDT 2016



Sent from my iPhone

On Apr 25, 2016, at 10:03 PM, Brent Royal-Gordon <brent at architechies.com> wrote:

>> Note that, if we do the above, I’d love to make it an error to define a new associated type with the same name as an associated type in an inherited protocol. It’s odd that we do so, and IIRC the only use case for it is to add requirement to an “existing” associated type.
> 
> You also do it to specify or change a default associated type. This is from an older copy of the stdlib source code, but I believe there's still something equivalent:
> 
>    public protocol CollectionType : Indexable, SequenceType {
>      associatedtype Generator: GeneratorType = IndexingGenerator<Self>

Ah yes, of course! Thank you. 

  - Doug


More information about the swift-evolution mailing list