<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="">Hi Cao,<div class=""><br class=""></div><div class="">Note that Optional&lt;T&gt; already supports covariance as well as an “injection” from T to Optional&lt;T&gt;:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">class A{</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">}</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">class B:A {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">}</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">let b: B? = B() &nbsp;// conversion from B to B?</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">let a: A? = b &nbsp; &nbsp;// conversion from B? to A?</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div style="margin: 0px; line-height: normal;" class="">This is special-cased by the type checker, and not exposed for use by user-defined types such as Either in your example.</div><div style="margin: 0px; line-height: normal;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class="">&nbsp;</div><div><blockquote type="cite" class=""><div class="">On Feb 15, 2016, at 10:36 PM, Cao Jiannan via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=gb2312" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">So the Optional&lt;UITableView&gt; should be union(UITableView, None)</div><div class="">and Optional&lt;MyTableVIew&gt; should be union(MyTableView, None), which is subclass of union(UITableView, None)</div></div></div></blockquote><div><br class=""></div><div>But you can still have generic type parameters here, if your function is generic over T and you write union(T, SomeOtherType). How would that work?</div><div><br class=""></div><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="">This is a final rational solution. I think.</div><div class=""><br class=""></div><div class="">-Jiannan</div><div class=""><br class=""><blockquote type="cite" class=""><div class="">下面是被转发的邮件:</div><br class="Apple-interchange-newline"><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;" class=""><span style="font-family: -webkit-system-font, 'Helvetica Neue', Helvetica, sans-serif;" class=""><b class="">发件人: </b></span><span style="font-family: -webkit-system-font, Helvetica Neue, Helvetica, sans-serif;" class="">Cao Jiannan via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt;<br class=""></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;" class=""><span style="font-family: -webkit-system-font, 'Helvetica Neue', Helvetica, sans-serif;" class=""><b class="">主题: </b></span><span style="font-family: -webkit-system-font, Helvetica Neue, Helvetica, sans-serif;" class=""><b class="">[swift-evolution]  Swift Generic Subtype Problem</b><br class=""></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;" class=""><span style="font-family: -webkit-system-font, 'Helvetica Neue', Helvetica, sans-serif;" class=""><b class="">日期: </b></span><span style="font-family: -webkit-system-font, Helvetica Neue, Helvetica, sans-serif;" class="">2016年2月16日 GMT+8 11:48:18<br class=""></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;" class=""><span style="font-family: -webkit-system-font, 'Helvetica Neue', Helvetica, sans-serif;" class=""><b class="">收件人: </b></span><span style="font-family: -webkit-system-font, Helvetica Neue, Helvetica, sans-serif;" class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;" class=""><span style="font-family: -webkit-system-font, 'Helvetica Neue', Helvetica, sans-serif;" class=""><b class="">回复-收件人: </b></span><span style="font-family: -webkit-system-font, Helvetica Neue, Helvetica, sans-serif;" class="">Cao Jiannan &lt;<a href="mailto:frogcjn@163.com" class="">frogcjn@163.com</a>&gt;<br class=""></span></div><br class=""><div class=""><meta http-equiv="Content-Type" content="text/html charset=gb2312" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><span style="color: rgb(51, 51, 51); font-family: inherit; font-size: 10pt; font-style: inherit;" class=""><br class=""></span></div><span style="color: rgb(51, 51, 51); font-family: inherit; font-size: 10pt; font-style: inherit;" class="">Hi all,</span><br class=""><div class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><span class="" style="font-family: inherit; color: rgb(51, 51, 51); font-size: 10pt; font-style: inherit;">I&nbsp;</span><font color="#333333" face="Helvetica Neue" size="2" class="" style="font-family: 'Helvetica Neue';">want to discuss on a&nbsp;</font><span style="color: rgb(51, 51, 51); font-family: 'Helvetica Neue'; font-size: small;" class="">problem</span>&nbsp; about&nbsp;<span style="font-family: 'Helvetica Neue'; color: rgb(51, 51, 51); font-size: small;" class="">optional generic&nbsp;sub-typing.</span></div><div class=""><div class=""><br class=""></div><div class=""><div class="">This is my suggesion.</div><div class=""><br class=""></div></div><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class="">if B is subclass of A</div><div class="">Either&lt;B,B&gt; is subclass of Either&lt;A,A&gt;, Either&lt;A,B&gt;, Either&lt;B,A&gt;</div><div class="">Either&lt;B,A&gt; is subclass of Either&lt;A,A&gt;</div><div class=""><div class="">Either&lt;A,B&gt; is subclass of Either&lt;A,A&gt;</div><div class=""><br class=""></div></div></div></div></div></div><blockquote type="cite" class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""></div><div class=""></div></div></div></div></div></blockquote></div><div class="">Why? Let’s see an example code in a real project:</div><div class=""><br class=""></div><div class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="margin: 0px 0px 0px 6px; line-height: normal;" class=""><br class=""></div><div style="margin: 0px 0px 0px 6px; line-height: normal; font-family: 'Helvetica Neue';" class=""><span style="color: rgb(51, 51, 51); font-family: inherit; font-size: 10pt; font-style: inherit;" class=""><br class=""></span></div><div style="margin: 0px 0px 0px 6px; line-height: normal; font-family: 'Helvetica Neue';" class=""><span style="color: rgb(51, 51, 51); font-family: inherit; font-size: 10pt; font-style: inherit;" class="">Here is a protocol type for some UIViewController,</span></div><div class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><div class="dp-highlighter" style="box-sizing: border-box; padding: 1px 0px 0px; border: none; font-family: Consolas, 'Courier New', Courier, mono, serif; vertical-align: baseline; background-color: rgb(249, 249, 249); width: auto; overflow: visible; color: rgb(51, 51, 51); margin: 0px !important;"><div class="bar" style="box-sizing: border-box; margin: 0px; padding: 0px 0px 0px 45px; border: 0px; font-style: inherit; font-family: inherit; vertical-align: baseline;"><div class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-family: inherit; vertical-align: baseline;"></div></div><ol start="1" class="dp-j" style="box-sizing: border-box; padding: 0px; border: none; font-style: inherit; font-family: inherit; vertical-align: baseline; list-style-position: initial; list-style-image: initial; background-color: rgb(255, 255, 255); color: rgb(92, 92, 92); margin: 0px 0px 1px 45px !important;"><li class="alt" style="box-sizing: border-box; border-left-width: 3px; border-style: none none none solid; border-left-color: rgb(255, 255, 255); font-style: inherit; font-size: 1em; font-family: inherit; vertical-align: baseline; line-height: 12pt; list-style: decimal-leading-zero outside; color: inherit; height: 12pt; position: relative; white-space: nowrap; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; vertical-align: baseline; background-color: inherit; font-size: 9pt !important;">protocol&nbsp;&nbsp;SegueHandlerType&nbsp;{&nbsp;&nbsp;</span></li><li class="" style="box-sizing: border-box; border-left-width: 3px; border-style: none none none solid; border-left-color: rgb(255, 255, 255); font-style: inherit; font-size: 1em; font-family: inherit; vertical-align: baseline; line-height: 12pt; list-style: decimal-leading-zero outside; background-color: rgb(248, 248, 248); height: 12pt; position: relative; white-space: nowrap; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; vertical-align: baseline; background-color: inherit; font-size: 9pt !important;">&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;tableView:&nbsp;UITableView!&nbsp;{&nbsp;get&nbsp;}&nbsp;&nbsp;</span></li><li class="alt" style="box-sizing: border-box; border-left-width: 3px; border-style: none none none solid; border-left-color: rgb(255, 255, 255); font-style: inherit; font-size: 1em; font-family: inherit; vertical-align: baseline; line-height: 12pt; list-style: decimal-leading-zero outside; color: inherit; height: 12pt; position: relative; white-space: nowrap; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; vertical-align: baseline; background-color: inherit; font-size: 9pt !important;">}&nbsp;&nbsp;</span></li></ol></div><div class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-size: 16px; font-family: 'Myriad Set Pro', 'Lucida Grande', 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; vertical-align: baseline; line-height: 1.4737em; color: rgb(51, 51, 51);"><br class=""></div><div class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-size: 16px; font-family: 'Myriad Set Pro', 'Lucida Grande', 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; vertical-align: baseline; line-height: 1.4737em; color: rgb(51, 51, 51);"><span class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-size: 10pt; font-family: inherit; vertical-align: baseline;">so the UITableViewController can conform to the protocal</span></div><div class="dp-highlighter" style="box-sizing: border-box; padding: 1px 0px 0px; border: none; font-family: Consolas, 'Courier New', Courier, mono, serif; vertical-align: baseline; background-color: rgb(249, 249, 249); width: auto; overflow: visible; color: rgb(51, 51, 51); margin: 0px !important;"><div class="bar" style="box-sizing: border-box; margin: 0px; padding: 0px 0px 0px 45px; border: 0px; font-style: inherit; font-family: inherit; vertical-align: baseline;"><div class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-family: inherit; vertical-align: baseline;"></div></div><ol start="1" class="dp-j" style="box-sizing: border-box; padding: 0px; border: none; font-style: inherit; font-family: inherit; vertical-align: baseline; list-style-position: initial; list-style-image: initial; background-color: rgb(255, 255, 255); color: rgb(92, 92, 92); margin: 0px 0px 1px 45px !important;"><li class="alt" style="box-sizing: border-box; border-left-width: 3px; border-style: none none none solid; border-left-color: rgb(255, 255, 255); font-style: inherit; font-size: 1em; font-family: inherit; vertical-align: baseline; line-height: 12pt; list-style: decimal-leading-zero outside; color: inherit; height: 12pt; position: relative; white-space: nowrap; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; vertical-align: baseline; background-color: inherit; font-size: 9pt !important;">extension&nbsp;UITableViewController&nbsp;:&nbsp;SegueHandlerType&nbsp;{&nbsp;&nbsp;</span></li><li class="" style="box-sizing: border-box; border-left-width: 3px; border-style: none none none solid; border-left-color: rgb(255, 255, 255); font-style: inherit; font-size: 1em; font-family: inherit; vertical-align: baseline; line-height: 12pt; list-style: decimal-leading-zero outside; background-color: rgb(248, 248, 248); height: 12pt; position: relative; white-space: nowrap; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; vertical-align: baseline; background-color: inherit; font-size: 9pt !important;">}&nbsp;&nbsp;</span></li></ol></div><div class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-size: 16px; font-family: 'Myriad Set Pro', 'Lucida Grande', 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; vertical-align: baseline; line-height: 1.4737em; color: rgb(51, 51, 51);"><span class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-size: 10pt; font-family: inherit; vertical-align: baseline;"><br class="" style="box-sizing: border-box;"></span></div><div class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-size: 16px; font-family: 'Myriad Set Pro', 'Lucida Grande', 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; vertical-align: baseline; line-height: 1.4737em; color: rgb(51, 51, 51);"><span class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-size: 10pt; font-family: inherit; vertical-align: baseline;">It's great!</span></div><div class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-size: 16px; font-family: 'Myriad Set Pro', 'Lucida Grande', 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; vertical-align: baseline; line-height: 1.4737em; color: rgb(51, 51, 51);"><span class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-size: 10pt; font-family: inherit; vertical-align: baseline;">What if the tableView is a subclass UITableView?</span></div><div class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-size: 16px; font-family: 'Myriad Set Pro', 'Lucida Grande', 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; vertical-align: baseline; line-height: 1.4737em; color: rgb(51, 51, 51);"><span class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-size: 10pt; font-family: inherit; vertical-align: baseline;">like:</span></div><div class="dp-highlighter" style="box-sizing: border-box; padding: 1px 0px 0px; border: none; font-family: Consolas, 'Courier New', Courier, mono, serif; vertical-align: baseline; background-color: rgb(249, 249, 249); width: auto; overflow: visible; color: rgb(51, 51, 51); margin: 0px !important;"><div class="bar" style="box-sizing: border-box; margin: 0px; padding: 0px 0px 0px 45px; border: 0px; font-style: inherit; font-family: inherit; vertical-align: baseline;"><div class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-family: inherit; vertical-align: baseline;"></div></div><ol start="1" class="dp-j" style="box-sizing: border-box; padding: 0px; border: none; font-style: inherit; font-family: inherit; vertical-align: baseline; list-style-position: initial; list-style-image: initial; background-color: rgb(255, 255, 255); color: rgb(92, 92, 92); margin: 0px 0px 1px 45px !important;"><li class="alt" style="box-sizing: border-box; border-left-width: 3px; border-style: none none none solid; border-left-color: rgb(255, 255, 255); font-style: inherit; font-size: 1em; font-family: inherit; vertical-align: baseline; line-height: 12pt; list-style: decimal-leading-zero outside; color: inherit; height: 12pt; position: relative; white-space: nowrap; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; vertical-align: baseline; background-color: inherit; font-size: 9pt !important;">class MyTableView : UITableView {</span></li><li class="alt" style="box-sizing: border-box; border-left-width: 3px; border-style: none none none solid; border-left-color: rgb(255, 255, 255); font-style: inherit; font-size: 1em; font-family: inherit; vertical-align: baseline; line-height: 12pt; list-style: decimal-leading-zero outside; color: inherit; height: 12pt; position: relative; white-space: nowrap; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; vertical-align: baseline; background-color: inherit; font-size: 9pt !important;">}</span></li><li class="alt" style="box-sizing: border-box; border-left-width: 3px; border-style: none none none solid; border-left-color: rgb(255, 255, 255); font-style: inherit; font-size: 1em; font-family: inherit; vertical-align: baseline; line-height: 12pt; list-style: decimal-leading-zero outside; color: inherit; height: 12pt; position: relative; white-space: nowrap; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; vertical-align: baseline; background-color: inherit; font-size: 9pt !important;"><br class=""></span></li><li class="alt" style="box-sizing: border-box; border-left-width: 3px; border-style: none none none solid; border-left-color: rgb(255, 255, 255); font-style: inherit; font-size: 1em; font-family: inherit; vertical-align: baseline; line-height: 12pt; list-style: decimal-leading-zero outside; color: inherit; height: 12pt; position: relative; white-space: nowrap; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; vertical-align: baseline; background-color: inherit; font-size: 9pt !important;">MyTableViewController&nbsp;{&nbsp;&nbsp;</span></li><li class="" style="box-sizing: border-box; border-left-width: 3px; border-style: none none none solid; border-left-color: rgb(255, 255, 255); font-style: inherit; font-size: 1em; font-family: inherit; vertical-align: baseline; line-height: 12pt; list-style: decimal-leading-zero outside; background-color: rgb(248, 248, 248); height: 12pt; position: relative; white-space: nowrap; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; vertical-align: baseline; background-color: inherit; font-size: 9pt !important;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="annotation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; vertical-align: baseline; color: rgb(100, 100, 100); background-color: inherit; font-size: 9pt !important;">@IBOutlet</span><span class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; vertical-align: baseline; background-color: inherit; font-size: 9pt !important;">&nbsp;var&nbsp;tableView:&nbsp;MyTableView! &nbsp;</span></span></li><li class="" style="box-sizing: border-box; border-left-width: 3px; border-style: none none none solid; border-left-color: rgb(255, 255, 255); font-style: inherit; font-size: 1em; font-family: inherit; vertical-align: baseline; line-height: 12pt; list-style: decimal-leading-zero outside; background-color: rgb(248, 248, 248); height: 12pt; position: relative; white-space: nowrap; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; vertical-align: baseline; background-color: inherit; font-size: 9pt !important;">}&nbsp;&nbsp;</span></li></ol></div><div class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-size: 16px; font-family: 'Myriad Set Pro', 'Lucida Grande', 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; vertical-align: baseline; line-height: 1.4737em; color: rgb(51, 51, 51);"><br class=""></div><div class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-size: 16px; font-family: 'Myriad Set Pro', 'Lucida Grande', 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; vertical-align: baseline; line-height: 1.4737em; color: rgb(51, 51, 51);"><span class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-size: 10pt; font-family: inherit; vertical-align: baseline;">Then&nbsp;</span></div><div class="dp-highlighter" style="box-sizing: border-box; padding: 1px 0px 0px; border: none; font-family: Consolas, 'Courier New', Courier, mono, serif; vertical-align: baseline; background-color: rgb(249, 249, 249); width: auto; overflow: visible; color: rgb(51, 51, 51); margin: 0px !important;"><div class="bar" style="box-sizing: border-box; margin: 0px; padding: 0px 0px 0px 45px; border: 0px; font-style: inherit; font-family: inherit; vertical-align: baseline;"><div class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-family: inherit; vertical-align: baseline;"></div></div><ol start="1" class="dp-j" style="box-sizing: border-box; padding: 0px; border: none; font-style: inherit; font-family: inherit; vertical-align: baseline; list-style-position: initial; list-style-image: initial; background-color: rgb(255, 255, 255); color: rgb(92, 92, 92); margin: 0px 0px 1px 45px !important;"><li class="alt" style="box-sizing: border-box; border-left-width: 3px; border-style: none none none solid; border-left-color: rgb(255, 255, 255); font-style: inherit; font-size: 1em; font-family: inherit; vertical-align: baseline; line-height: 12pt; list-style: decimal-leading-zero outside; color: inherit; height: 12pt; position: relative; white-space: nowrap; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; vertical-align: baseline; background-color: inherit; font-size: 9pt !important;">extension&nbsp;MyTableViewController:SegueHandlerType&nbsp;{&nbsp;&nbsp;</span></li><li class="" style="box-sizing: border-box; border-left-width: 3px; border-style: none none none solid; border-left-color: rgb(255, 255, 255); font-style: inherit; font-size: 1em; font-family: inherit; vertical-align: baseline; line-height: 12pt; list-style: decimal-leading-zero outside; background-color: rgb(248, 248, 248); height: 12pt; position: relative; white-space: nowrap; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; vertical-align: baseline; background-color: inherit; font-size: 9pt !important;">&nbsp;&nbsp;</span></li><li class="alt" style="box-sizing: border-box; border-left-width: 3px; border-style: none none none solid; border-left-color: rgb(255, 255, 255); font-style: inherit; font-size: 1em; font-family: inherit; vertical-align: baseline; line-height: 12pt; list-style: decimal-leading-zero outside; color: inherit; height: 12pt; position: relative; white-space: nowrap; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; vertical-align: baseline; background-color: inherit; font-size: 9pt !important;">}&nbsp;&nbsp;</span></li></ol></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></blockquote></div></div></div></blockquote><div><br class=""></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=""><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=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><div class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-size: 16px; font-family: 'Myriad Set Pro', 'Lucida Grande', 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; line-height: 1.4737em;"><span style="font-family: Helvetica; font-size: 12px;" class="">will trigger a compiler error.</span><br style="font-family: Helvetica; font-size: 12px;" class=""></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></blockquote></div></div></div></blockquote><div><br class=""></div>The issue here is slightly different actually, but another interesting corner case that should be addressed. Protocol witness matching only looks at exact type equivalence, and not subtyping. So even without the ! it would hit the same issue:</div><div><br class=""></div><div>protocol P {</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>func f() -&gt; A</div><div>}</div><div><br class=""></div><div>class B : A {}</div><div><br class=""></div><div>class C : P {</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>func f() -&gt; B {} // compile error</div><div>}</div><div><br class=""></div><div>Once witness matching supports variance, your example will work.</div><div><br class=""></div><div>But a better way would be to use an associated type:</div><div><br class=""></div><div>protocol SequeHandlerType {</div><div>&nbsp; &nbsp; associatedtype View : UITableView</div><div>&nbsp; &nbsp;&nbsp;var tableView: View! { get }</div><div>}</div><div><br class=""></div><div>Now a witness can return any subclass of UITableView, which will unify with the View associated type. Furthermore, other requirements can also reference View and the type checker will ensure any conformance has the same View in all positions where it appears.</div><div><br class=""></div><div>Slava</div><div><br class=""></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=""><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=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><div class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-size: 16px; font-family: 'Myriad Set Pro', 'Lucida Grande', 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; line-height: 1.4737em;"><span style="font-family: Helvetica; font-size: 12px;" class="">&nbsp;</span><br style="font-family: Helvetica; font-size: 12px;" class=""><span style="font-family: Helvetica; font-size: 12px;" class="">So the Optional needs a subclass system.</span><br style="font-family: Helvetica; font-size: 12px;" class=""><span style="font-family: Helvetica; font-size: 12px;" class="">Or to say, that the template system needs a subclass system.</span><br style="font-family: Helvetica; font-size: 12px;" class=""><span style="font-family: Helvetica; font-size: 12px;" class="">&nbsp;</span><br style="font-family: Helvetica; font-size: 12px;" class=""><span style="font-family: Helvetica; font-size: 12px;" class="">Optional&lt;UITableView&gt; should be the super type of Optional&lt;MyTableView&gt;</span><br style="font-family: Helvetica; font-size: 12px;" class=""><span style="font-family: Helvetica; font-size: 12px;" class="">Array&lt;UITableView&gt; should be the super type of Array&lt;MyTableView&gt;</span></div></div><div class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-size: 16px; font-family: 'Myriad Set Pro', 'Lucida Grande', 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; vertical-align: baseline; line-height: 1.4737em; color: rgb(51, 51, 51);"><br class=""></div><div class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; line-height: 1.4737em;"><font color="#333333" face="Myriad Set Pro, Lucida Grande, Helvetica Neue, Helvetica, Arial, Verdana, sans-serif" size="3" class=""><a href="https://forums.developer.apple.com/message/101646#101646" class="">https://forums.developer.apple.com/message/101646#101646</a></font></div></div></div></div></div></div><blockquote type="cite" class=""><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"></div></div></div></div></div></blockquote></div><div class=""><br class=""></div><div class=""><div class=""><br class=""></div></div><div class=""><br class=""></div><div class="">Thanks!</div><div class=""><br class=""></div><div class="">Jiannan, Cao</div><div class=""><br class=""></div><div class=""><br class=""></div></div></div></div></div></div></div></div></div></div><br class=""></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></blockquote></div><br class=""></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=""></div></body></html>