[Pitch] `init` accessors

In general, I think inferring information about init accessor signatures from the bodies of other accessors is a recipe for confusion, because you will no longer get useful diagnostics if you accidentally access something you didn't mean to in the body of an init accessor. But I also don't think it's possible, because getters and setters would use initializes and accesses dependencies in the same way, but the initialization semantics are completely different between those two dependencies. The former states that the init accessor subsumes the initialization of a stored property, and the latter states that the init accessor relies on the stored property already being initialized at the point when the accessor is called. This difference will change how the compiler treats an assignment in the type's initializer during definite initialization analysis, and because the other accessors would use those dependencies in the same way after all of self is initialized, it's not possible to infer.

Yeah, I think init accessors on computed properties in extensions should be banned. It might be possible to support this in extensions inside the defining module of the type, but I don't think that's a good idea because you'd be able to write an extension that breaks initializers that might be implemented in a completely different file. That doesn't sound like a great programming experience.

2 Likes