[swift-evolution] Add code to super methods.

Tino Heth 2th at gmx.de
Sun Nov 20 10:00:33 CST 2016

> I'm not sure I follow your meaning on omission; I quite like Sean's suggestion of having an override(before) or override(final) in the sub-class, this way the call is explicitly auto-generated. I think having it be added automatically in the regular override case could be a bit confusing, I think a warning or error is better in that case as it should be visible so you know exactly when it is being called, the other cases don't need it (as they have the extra information on the override).
It's always possible to construct examples where there order is important, but I guess those won't matter in real code — and it would feel very strange to me if one of the print-statements would cause an error:
override func f(input: Int) {
	super.f(input: input)

(even commands after a return statement compile just fine…)

It is different when the call to super would be inserted automatically:
I don't think that one of the choices is superior, so it should be up to the author to decide what is preferred.

I'm not sure if it is a good idea to generate calls to super at all — but it would be similar to willSet/didSet.

- Tino
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20161120/1803236a/attachment.html>

More information about the swift-evolution mailing list