<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Feb 21, 2017, at 10:53 PM, David Hart 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=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hello list,<div class=""><br class=""></div><div class="">Found out yesterday that you can’t extend all existentials in Swift:</div><div class=""><br class=""></div><div class=""><font face="Menlo" class="">protocol P1 {}</font></div><div class=""><font face="Menlo" class="">extension P1 {}</font></div><div class=""><font face="Menlo" class="">// works as expected</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class="">protocol P2 {}</font></div><div class=""><font face="Menlo" class="">extension P1 & P2 {}</font></div><div class=""><font face="Menlo" class="">// error: non-nominal type 'P1 & P2' cannot be extended</font></div></div></div></blockquote><div><br class=""></div>This will make name lookup rather complicated. I’d rather not do it. As Jacob mentions, you can almost simulate it with a constrained extension.</div><div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class="">extension Any {}</font></div><div class=""><font face="Menlo" class="">// error: non-nominal type 'Any' cannot be extended</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class="">extension AnyObject {}</font></div><div class=""><font face="Menlo" class="">// error: 'AnyObject' protocol cannot be extended</font></div></div></div></blockquote><div><br class=""></div>These two are by design. In the future, AnyObject will be ‘special’ (basically we want to model it as ‘Any & class’), and not a protocol.</div><div><br class=""></div><div>Slava</div><div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""></div><div class="">I’d like to write a proposal to lift some of those restrictions. But the question is: which should be lifted? <font face="Menlo" class="">P1 & P2</font> seems like an obvious case. But what about <font face="Menlo" class="">Any</font> and <font face="Menlo" class="">AnyObject</font>? Is there a design reason that we shouldn’t allow it?</div><div class=""><br class=""></div><div class="">David.</div></div>_______________________________________________<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=""></body></html>