[swift-evolution] [Pitch] Remove type inference for associated types

Brent Royal-Gordon brent at architechies.com
Thu Jun 30 07:53:05 CDT 2016

> On Jun 29, 2016, at 6:55 AM, Brandon Knope via swift-evolution <swift-evolution at swift.org> wrote:
> What's the rationale for having associatedtype in protocols and typealias in the conforming types?

I didn't design it, but here's how I think about it: The associated type requirement merely states that there must be a type with this name meeting these criteria. `typealias` is one way to satisfy that requirement, but you can also just define a nested type with that name:

	struct MyCollection {
		struct Index: Comparable { … }

Should you replace `struct` with `associatedtype`? No? Then why would you replace `typealias` with `associatedtype`?

Brent Royal-Gordon

More information about the swift-evolution mailing list