[swift-evolution] Why couldn't a class call any of its superclass' initializers?

John McCall rjmccall at apple.com
Wed Jul 26 00:18:34 CDT 2017


> On Jul 26, 2017, at 12:36 AM, Daryle Walker via swift-evolution <swift-evolution at swift.org> wrote:
> [Sorry if this's been discussed before.]
> 
> As long as the superclass sub-object gets initialized, it shouldn't matter if the initializer was designated or convenience. Is there some subtle step on the two-phase initialization I'm missing? Or is this a point to extend in a future version of Swift?

Convenience initializers are complete-object initializers.  A sub-object initializer from a subclass cannot delegate to a complete-object initializer from its superclass because that would re-initialize all the subclass sub-objects.

John.


More information about the swift-evolution mailing list