<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="">Also possibly related is the covariance in protocol requirements. The following example doesn’t compile without casting the arrays or single values to the exact types required in the protocols, despite being covariant through protocol conformance or subclass.<div class=""><br class=""></div><div class="">protocol HasViews {<br class="">&nbsp; &nbsp;&nbsp;<br class="">&nbsp; &nbsp; var views: [UIView]!<br class="">&nbsp; &nbsp;&nbsp;<br class="">}<br class=""><br class="">protocol Updateable { }<br class=""><br class="">extension UIView: Updateable { }<br class=""><br class="">protocol HasProtocols {<br class="">&nbsp; &nbsp;&nbsp;<br class="">&nbsp; &nbsp; var updateables: [Updateable]!<br class="">&nbsp; &nbsp;&nbsp;<br class="">}<br class=""><br class="">class ViewController: UIViewController {<br class="">&nbsp; &nbsp;&nbsp;<br class="">&nbsp; &nbsp; @IBOutlet var views: [UIButton]!<br class="">&nbsp; &nbsp; @IBOutlet var updateables: [UIButton]!<br class="">&nbsp; &nbsp;&nbsp;<br class="">}<br class=""><br class="">extension ViewController: HasViews { } // fails without casting<br class="">extension ViewController: HasProtocols { } // fails without casting</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Jon</div><div class=""><br class=""></div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Feb 20, 2017, at 7:07 PM, Howard Lovatt via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">It is confusing in Swift what can be covariant and what is invariant, consider:</div><div class=""><br class=""></div><div class=""><div class="">&nbsp; &nbsp; // Covarant arrays work</div><div class="">&nbsp; &nbsp; class A {}</div><div class="">&nbsp; &nbsp; class B: A {}</div><div class="">&nbsp; &nbsp; let a = A() // A</div><div class="">&nbsp; &nbsp; let b = B() // B</div><div class="">&nbsp; &nbsp; var arrayA = [a] // Array&lt;A&gt;</div><div class="">&nbsp; &nbsp; arrayA[0] = b // OK</div><div class="">&nbsp; &nbsp;&nbsp;</div><div class="">&nbsp; &nbsp; // And arrays of arrays</div><div class="">&nbsp; &nbsp; var arrayArrayA = [arrayA] // Array&lt;Array&lt;A&gt;&gt;</div><div class="">&nbsp; &nbsp; arrayArrayA[0][0] = b // OK</div><div class="">&nbsp; &nbsp; let arrayB = [b] // Array&lt;B&gt;</div><div class="">&nbsp; &nbsp; arrayArrayA[0] = arrayB // OK, works out that an Array&lt;B&gt; is a Array&lt;A&gt;</div><div class="">&nbsp; &nbsp;&nbsp;</div><div class=""><div class="">&nbsp; &nbsp; // Covariant homebrew-collections work</div><div class="">&nbsp; &nbsp; class C&lt;T: AnyObject&gt; {&nbsp;</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; var e: T</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; init(_ e: T) { self.e = e }</div><div class="">&nbsp; &nbsp; }</div><div class="">&nbsp; &nbsp; var cA = C(a) // C&lt;A&gt;</div><div class="">&nbsp; &nbsp; cA.e = b // OK</div><div class="">&nbsp; &nbsp;&nbsp;</div><div class="">&nbsp; &nbsp; // But not quite for homebrew-collections of homebrew-collections</div><div class="">&nbsp; &nbsp; var cCA = C(cA) // C&lt;C&lt;A&gt;&gt;</div><div class="">&nbsp; &nbsp; cCA.e.e = b // OK</div><div class="">&nbsp; &nbsp; let cB = C(b) // C&lt;B&gt;</div><div class="">&nbsp; &nbsp; // cCA.e = cB // Error - cannot work out that a C&lt;B&gt; is a C&lt;A&gt; but can do so for arrays</div></div><div class=""><br class=""></div><div class="">It is weird that the last line fails and the equivalent Array line doesn't. I suspect that there is some special typing going on for arrays, probably to make them play nice with Objective-C. However it would be simpler if everything was covariant when safe to be covariant, i.e. The last line should work.</div><div class=""><br class=""></div><div class="">&nbsp;-- Howard.</div><div class=""><br class=""></div><div class="gmail_quote"><div class="">On Mon, 20 Feb 2017 at 8:38 pm, Isaac Rivera via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg"><font size="2" class="gmail_msg">I can see it is a (counter-intuitive) language design decision for type safety… but then why, in the code below I can:</font></div><div class="gmail_msg"><div style="margin:0px;line-height:normal;font-family:Menlo;min-height:18px" class="gmail_msg"><font size="2" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"></span><br class="gmail_msg"></font></div><div style="margin:0px;line-height:normal;font-family:Menlo;color:rgb(97,34,174)" class="gmail_msg"><font size="2" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:#c42275" class="gmail_msg">class</span><span style="font-variant-ligatures: no-common-ligatures;" class="gmail_msg">&nbsp;OtherThing: </span><span style="font-variant-ligatures:no-common-ligatures;color:#3c828b" class="gmail_msg">Something</span><span style="font-variant-ligatures: no-common-ligatures;" class="gmail_msg">&lt;</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">UIViewController</span><span style="font-variant-ligatures: no-common-ligatures;" class="gmail_msg">&gt; {</span></font></div><div style="margin:0px;line-height:normal;font-family:Menlo" class="gmail_msg"><font size="2" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><span class="gmail_msg m_-1818902889843361492Apple-tab-span" style="white-space:pre-wrap">        </span></span><span style="font-variant-ligatures:no-common-ligatures;color:#c42275" class="gmail_msg">override</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#c42275" class="gmail_msg">func</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> start(</span><span style="font-variant-ligatures:no-common-ligatures;color:#c42275" class="gmail_msg">_</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> completion: </span><span style="font-variant-ligatures:no-common-ligatures;color:#539aa4" class="gmail_msg">SomeCallback</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">? = </span><span style="font-variant-ligatures:no-common-ligatures;color:#c42275" class="gmail_msg">nil</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">) {</span></font></div><div style="margin:0px;line-height:normal;font-family:Menlo;color:rgb(30,148,33)" class="gmail_msg"><font size="2" class="gmail_msg"><span style="font-variant-ligatures: no-common-ligatures;" class="gmail_msg"><span class="gmail_msg m_-1818902889843361492Apple-tab-span" style="white-space:pre-wrap">                </span></span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">// implementation details...</span></font></div><div style="margin:0px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><font size="2" class="gmail_msg"><span class="gmail_msg m_-1818902889843361492Apple-tab-span" style="white-space:pre-wrap">        </span>}</font></span></div><div style="margin:0px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><font size="2" class="gmail_msg">}</font></span></div><div style="margin:0px;line-height:normal;font-family:Menlo;min-height:18px" class="gmail_msg"><font size="2" class="gmail_msg"><br class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"></span></font></div><div style="margin:0px;line-height:normal;font-family:Menlo" class="gmail_msg"><font size="2" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:#c42275" class="gmail_msg">let</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> firstThing =&nbsp;</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">OtherThing(viewController: </span><span style="font-variant-ligatures:no-common-ligatures;color:#6122ae" class="gmail_msg">UINavigationController</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">())</span></font></div></div><div style="margin:0px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><font size="2" class="gmail_msg"><br class="gmail_msg"></font></span></div><div style="margin:0px;line-height:normal;font-family:Menlo" class="gmail_msg"><font size="2" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">OtherThing extends&nbsp;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(60,130,139)" class="gmail_msg">Something</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">&lt;</span><span style="color:rgb(97,34,174);font-variant-ligatures:no-common-ligatures" class="gmail_msg">UIViewController</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">&gt;… but I can instantiate it with the subtype…</span></font></div><div style="margin:0px;line-height:normal;font-family:Menlo" class="gmail_msg"><font size="2" class="gmail_msg"><br class="gmail_msg"></font></div><div style="margin:0px;line-height:normal;font-family:Menlo" class="gmail_msg"><font size="2" class="gmail_msg">Ok you will say, UINavigationController is a subtype of UIViewController, but that still does not make&nbsp;<span style="font-variant-ligatures:no-common-ligatures;color:rgb(60,130,139)" class="gmail_msg">Something</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">&lt;</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><span style="color:rgb(97,34,174)" class="gmail_msg">UINavigationController</span>&gt; a subtype of&nbsp;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(60,130,139)" class="gmail_msg">Something</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">&lt;</span><span style="color:rgb(97,34,174);font-variant-ligatures:no-common-ligatures" class="gmail_msg">UIViewController</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">&gt;.&nbsp;</span></font></div><div style="margin:0px;line-height:normal;font-family:Menlo" class="gmail_msg"><font size="2" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><br class="gmail_msg"></span></font></div><div style="margin:0px;line-height:normal;font-family:Menlo" class="gmail_msg"><font size="2" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">Fair enough, but:</span></font></div><div style="margin:0px;line-height:normal;font-family:Menlo" class="gmail_msg"><font size="2" class="gmail_msg"><br class="gmail_msg"></font></div><div style="margin:0px;line-height:normal;font-family:Menlo" class="gmail_msg"><div style="margin:0px;line-height:normal;color:rgb(97,34,174)" class="gmail_msg"><font size="2" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:#c42275" class="gmail_msg">let</span><span style="font-variant-ligatures: no-common-ligatures;" class="gmail_msg"> c1: </span><span style="font-variant-ligatures:no-common-ligatures;color:#3c828b" class="gmail_msg">Something</span><span style="font-variant-ligatures: no-common-ligatures;" class="gmail_msg">&lt;</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">UIViewController</span><span style="font-variant-ligatures: no-common-ligatures;" class="gmail_msg">&gt; = </span><span style="font-variant-ligatures:no-common-ligatures;color:#3c828b" class="gmail_msg">Something</span><span style="font-variant-ligatures: no-common-ligatures;" class="gmail_msg">(viewController: </span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">UINavigationController</span><span style="font-variant-ligatures: no-common-ligatures;" class="gmail_msg">())</span></font></div><div style="margin:0px;line-height:normal;color:rgb(97,34,174)" class="gmail_msg"><font size="2" class="gmail_msg"><span style="font-variant-ligatures: no-common-ligatures;" class="gmail_msg">// c1 is of type "</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(60,130,139)" class="gmail_msg">Something</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">&lt;</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">UIViewController</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">&gt;"</span></font></div><div style="margin:0px;line-height:normal;color:rgb(97,34,174)" class="gmail_msg"><span style="font-variant-ligatures: no-common-ligatures;" class="gmail_msg"><font size="2" class="gmail_msg"><br class="gmail_msg"></font></span></div><div style="margin:0px;line-height:normal" class="gmail_msg"><font size="2" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:#c42275" class="gmail_msg">let</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> c2 = </span><span style="font-variant-ligatures:no-common-ligatures;color:#3c828b" class="gmail_msg">Something</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">(viewController: </span><span style="font-variant-ligatures:no-common-ligatures;color:#6122ae" class="gmail_msg">UINavigationController</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">())</span></font></div></div><div style="margin:0px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><font size="2" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">// c1 is of type "</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(60,130,139)" class="gmail_msg">Something</span><span style="color:rgb(97,34,174);font-variant-ligatures:no-common-ligatures" class="gmail_msg">&lt;</span><span style="color:rgb(97,34,174);font-variant-ligatures:no-common-ligatures" class="gmail_msg">UINavigationController&gt;”</span></font></span></div><div style="margin:0px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><span style="color:rgb(97,34,174);font-variant-ligatures:no-common-ligatures" class="gmail_msg"><font size="2" class="gmail_msg"><br class="gmail_msg"></font></span></span></div><div style="margin:0px;line-height:normal;font-family:Menlo" class="gmail_msg"><font size="2" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><span style="color:rgb(97,34,174);font-variant-ligatures:no-common-ligatures" class="gmail_msg">So it appears&nbsp;</span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(60,130,139)" class="gmail_msg">Something</span><span style="color:rgb(97,34,174);font-variant-ligatures:no-common-ligatures" class="gmail_msg">&lt;</span><span style="color:rgb(97,34,174);font-variant-ligatures:no-common-ligatures" class="gmail_msg">UINavigationController&gt; can be cast to type&nbsp;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(60,130,139)" class="gmail_msg">Something</span><span style="color:rgb(97,34,174);font-variant-ligatures:no-common-ligatures" class="gmail_msg">&lt;</span><span style="color:rgb(97,34,174);font-variant-ligatures:no-common-ligatures" class="gmail_msg">UIViewController</span><span style="color:rgb(97,34,174);font-variant-ligatures:no-common-ligatures" class="gmail_msg">&gt;…</span></font></div><div style="margin:0px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="color:rgb(97,34,174);font-variant-ligatures:no-common-ligatures" class="gmail_msg"><font size="2" class="gmail_msg"><br class="gmail_msg"></font></span></div><div style="margin:0px;line-height:normal;font-family:Menlo" class="gmail_msg"><font color="#6122ae" size="2" class="gmail_msg">Yet this is illegal?</font></div><div style="margin:0px;line-height:normal;font-family:Menlo" class="gmail_msg"><font color="#6122ae" size="2" class="gmail_msg"><br class="gmail_msg"></font></div><div style="margin:0px;line-height:normal;font-family:Menlo" class="gmail_msg"><div style="margin:0px;line-height:normal" class="gmail_msg"><font size="2" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:#c42275" class="gmail_msg">let</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> somethings: [</span><span style="font-variant-ligatures:no-common-ligatures;color:#3c828b" class="gmail_msg">Something</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">&lt;</span><span style="font-variant-ligatures:no-common-ligatures;color:#6122ae" class="gmail_msg">UIViewController</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">&gt;] = [</span><span style="font-variant-ligatures:no-common-ligatures;color:#539aa4" class="gmail_msg">c1</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">, </span><span style="font-variant-ligatures:no-common-ligatures;color:#539aa4" class="gmail_msg">c2</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">]</span></font></div><div style="margin:0px;line-height:normal" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><font size="2" class="gmail_msg"><br class="gmail_msg"></font></span></div><div style="margin:0px;line-height:normal" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><font size="2" class="gmail_msg">I dont know, something seems inconsistent.</font></span></div><div style="font-size:15px;margin:0px;line-height:normal" class="gmail_msg"><br class="gmail_msg"></div></div></div><div style="word-wrap:break-word" class="gmail_msg"><br class="gmail_msg"><div class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg">On Feb 16, 2017, at 10:59 PM, Slava Pestov &lt;<a href="mailto:spestov@apple.com" class="gmail_msg" target="_blank">spestov@apple.com</a>&gt; wrote:</div><br class="gmail_msg m_-1818902889843361492Apple-interchange-newline"><div class="gmail_msg"><div class="gmail_msg">Hi Isaac,<br class="gmail_msg"><br class="gmail_msg">This is not about associated types. Rather, the issue is that a ‘Thing’ is a ‘Something&lt;UINavigationController&gt;’, but you are casting it to ‘Something&lt;UIViewController&gt;’. The two types are not related; in general, if A is a subtype of B, then G&lt;A&gt; is not a subtype of G&lt;B&gt;.<br class="gmail_msg"><br class="gmail_msg"><a href="https://en.wikipedia.org/wiki/Covariance_and_contravariance_(computer_science)" class="gmail_msg" target="_blank">https://en.wikipedia.org/wiki/Covariance_and_contravariance_(computer_science)</a><br class="gmail_msg"><br class="gmail_msg">Slava<br class="gmail_msg"><br class="gmail_msg"><blockquote type="cite" class="gmail_msg">On Feb 16, 2017, at 9:05 AM, Isaac Rivera via swift-users &lt;<a href="mailto:swift-users@swift.org" class="gmail_msg" target="_blank">swift-users@swift.org</a>&gt; wrote:<br class="gmail_msg"><br class="gmail_msg">Hello, list!<br class="gmail_msg"><br class="gmail_msg">I am trying to find my way around Swift’s protocol limitations. It appears that in general, any protocol with declared associatedtype will break polymorphism?<br class="gmail_msg"><br class="gmail_msg">Take the case below which does not compile. All "Thing” instances are "Something&lt;VC: UIViewController&gt;” but they can’t be passed around or coerced as so.<br class="gmail_msg"><br class="gmail_msg">How is it that I can legally write the code:<br class="gmail_msg"><br class="gmail_msg">class Thing: Something&lt;UINavigationController&gt; { }<br class="gmail_msg"><br class="gmail_msg">and instantiate it, but it is not the very thing it implements? <br class="gmail_msg"><br class="gmail_msg">All Thing instances conform to the public interfaces of Something&lt;UIViewController&gt; so why can’t they be recognized as such and coerced as such?<br class="gmail_msg"><br class="gmail_msg">What is the work-around of this break in Polymorphism?<br class="gmail_msg"><br class="gmail_msg">import UIKit<br class="gmail_msg"><br class="gmail_msg">protocol Anything: class, NSObjectProtocol {<br class="gmail_msg"><span class="gmail_msg m_-1818902889843361492Apple-tab-span" style="white-space:pre-wrap">        </span><br class="gmail_msg"><span class="gmail_msg m_-1818902889843361492Apple-tab-span" style="white-space:pre-wrap">        </span>associatedtype ViewControllerType: UIViewController<br class="gmail_msg"><span class="gmail_msg m_-1818902889843361492Apple-tab-span" style="white-space:pre-wrap">        </span><br class="gmail_msg"><span class="gmail_msg m_-1818902889843361492Apple-tab-span" style="white-space:pre-wrap">        </span>var viewController: ViewControllerType { get }<br class="gmail_msg"><span class="gmail_msg m_-1818902889843361492Apple-tab-span" style="white-space:pre-wrap">        </span><br class="gmail_msg"><span class="gmail_msg m_-1818902889843361492Apple-tab-span" style="white-space:pre-wrap">        </span>init(viewController: ViewControllerType)<br class="gmail_msg"><span class="gmail_msg m_-1818902889843361492Apple-tab-span" style="white-space:pre-wrap">        </span><br class="gmail_msg"><span class="gmail_msg m_-1818902889843361492Apple-tab-span" style="white-space:pre-wrap">        </span>func addAnything(anything: Something&lt;UIViewController&gt;) -&gt; Bool<br class="gmail_msg">}<br class="gmail_msg"><br class="gmail_msg">class Something&lt;VC: UIViewController&gt;: NSObject, Anything {<br class="gmail_msg"><span class="gmail_msg m_-1818902889843361492Apple-tab-span" style="white-space:pre-wrap">        </span><br class="gmail_msg"><span class="gmail_msg m_-1818902889843361492Apple-tab-span" style="white-space:pre-wrap">        </span>typealias ViewControllerType = VC<br class="gmail_msg"><span class="gmail_msg m_-1818902889843361492Apple-tab-span" style="white-space:pre-wrap">        </span><br class="gmail_msg"><span class="gmail_msg m_-1818902889843361492Apple-tab-span" style="white-space:pre-wrap">        </span>private(set) var viewController: ViewControllerType<br class="gmail_msg"><span class="gmail_msg m_-1818902889843361492Apple-tab-span" style="white-space:pre-wrap">        </span><br class="gmail_msg"><span class="gmail_msg m_-1818902889843361492Apple-tab-span" style="white-space:pre-wrap">        </span>required init(viewController: ViewControllerType) { self.viewController = viewController }<br class="gmail_msg"><span class="gmail_msg m_-1818902889843361492Apple-tab-span" style="white-space:pre-wrap">        </span><br class="gmail_msg"><span class="gmail_msg m_-1818902889843361492Apple-tab-span" style="white-space:pre-wrap">        </span>final private var things = [String: Something&lt;UIViewController&gt;]()<br class="gmail_msg"><span class="gmail_msg m_-1818902889843361492Apple-tab-span" style="white-space:pre-wrap">        </span><br class="gmail_msg"><span class="gmail_msg m_-1818902889843361492Apple-tab-span" style="white-space:pre-wrap">        </span>final internal func addAnything(anything: Something&lt;UIViewController&gt;) -&gt; Bool {<br class="gmail_msg"><span class="gmail_msg m_-1818902889843361492Apple-tab-span" style="white-space:pre-wrap">        </span><span class="gmail_msg m_-1818902889843361492Apple-tab-span" style="white-space:pre-wrap">        </span>// implementation details...<br class="gmail_msg"><span class="gmail_msg m_-1818902889843361492Apple-tab-span" style="white-space:pre-wrap">        </span><span class="gmail_msg m_-1818902889843361492Apple-tab-span" style="white-space:pre-wrap">        </span>return true<br class="gmail_msg"><span class="gmail_msg m_-1818902889843361492Apple-tab-span" style="white-space:pre-wrap">        </span>}<br class="gmail_msg">}<br class="gmail_msg"><br class="gmail_msg">class Thing: Something&lt;UINavigationController&gt; { }<br class="gmail_msg"><br class="gmail_msg">let firstThing = Thing(viewController: UINavigationController())<br class="gmail_msg">let secondThing = Thing(viewController: UINavigationController())<br class="gmail_msg"><br class="gmail_msg">firstThing.addAnything(anything: secondThing)<br class="gmail_msg"><br class="gmail_msg">// Playground execution failed: error: MyPlayground.playground:48:34: error: cannot convert value of type 'Thing' to expected argument type 'Something&lt;UIViewController&gt;'<br class="gmail_msg"><br class="gmail_msg">firstThing.addAnything(anything: secondThing as Something&lt;UIViewController&gt;)<br class="gmail_msg"><br class="gmail_msg">// Playground execution failed: error: MyPlayground.playground:48:34: error: cannot convert value of type 'Thing' to type 'Something&lt;UIViewController&gt;' in coercion<br class="gmail_msg"><br class="gmail_msg"><br class="gmail_msg"><br class="gmail_msg"><br class="gmail_msg">_______________________________________________<br class="gmail_msg">swift-users mailing list<br class="gmail_msg"><a href="mailto:swift-users@swift.org" class="gmail_msg" target="_blank">swift-users@swift.org</a><br class="gmail_msg"><a href="https://lists.swift.org/mailman/listinfo/swift-users" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-users</a><br class="gmail_msg"></blockquote><br class="gmail_msg"></div></div></blockquote></div><br class="gmail_msg"></div>_______________________________________________<br class="gmail_msg">
swift-users mailing list<br class="gmail_msg">
<a href="mailto:swift-users@swift.org" class="gmail_msg" target="_blank">swift-users@swift.org</a><br class="gmail_msg">
<a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-users</a><br class="gmail_msg">
</blockquote></div></div><div dir="ltr" class="">-- <br class=""></div><div data-smartmail="gmail_signature" class="">-- Howard.</div>
_______________________________________________<br class="">swift-users mailing list<br class=""><a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-users<br class=""></div></blockquote></div><br class=""></div></body></html>