<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">+1 to this. Anything that helps ensure inheritance is thought through carefully and used correctly is a win.<div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 16, 2015, at 10:32 AM, Vester Gottfried via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">Some class based libraries/frameworks expect the consumer to subclass certain classes and override specific method and require that the super implementation of an overridden method is being called.</div><div class=""><br class=""></div><div class="">Not calling the super implementation is a common source of bugs that may be prevented if the compiler checks if super is called, like it does in some cases of init().</div><div class=""><br class=""></div><div class="">Example:<br class=""></div><div class=""><br class=""></div><div class="">class Box {</div><div class=""> @requires_super<br class=""></div><div class=""> func addStuff() { ... }</div><div class="">}<br class=""></div><div class=""><br class=""></div><div class="">Overriding class Box's addStuff without calling super.addStuff() should result in an error</div><div class=""><br class=""></div><div class="">class Chest : Box {</div><div class=""> override addStuff() {<br class=""></div><div class=""> // ERROR: addStuff() requires call to super.addStuff()</div><div class=""> ...</div><div class=""> }</div><div class="">}<br class=""></div><div class=""><br class=""></div><div class="">Objective-C developers know this as NS_REQUIRES_SUPER and I think its worth thinking about adapting it.</div><div class=""><div class=""><br class=""></div><div class="">I hope my proposal was clear and thanks for reading,</div><div class=""><br class=""></div></div><div class="">Gottfried</div></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=eLFMrKDT8iBxZ-2Fbnk-2BZqvSchNN-2FvYXdceA0T7VxwkAfetdXVtelgzCfab-2Fp92fvLNUbxvC5Ukh9mTRYtT7oZ-2BzUDHQ-2FkLVfwWHuXGWvz7iaXCPo1KAcjPGxoZUQTW8DMleErzJnIt-2FRMb1-2FEM1WN-2BscY0xmKk-2BmXO16SS-2BCT9-2B7dgbk1nlmgpvH5cNha2dTvKe3-2FSntENn88F21K4ayGJlZuPediCmd1qI2SGJLz5ZQ-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;" class="">
_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></div></body></html>