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

Brent Royal-Gordon brent at architechies.com
Tue Apr 26 00:03:18 CDT 2016


> 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>

-- 
Brent Royal-Gordon
Architechies



More information about the swift-evolution mailing list