<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 20, 2017, at 4:07 PM, Howard Lovatt <<a href="mailto:howard.lovatt@gmail.com" class="">howard.lovatt@gmail.com</a>> 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=""> // Covarant arrays work</div><div class=""> class A {}</div><div class=""> class B: A {}</div><div class=""> let a = A() // A</div><div class=""> let b = B() // B</div><div class=""> var arrayA = [a] // Array<A></div><div class=""> arrayA[0] = b // OK</div><div class=""> </div><div class=""> // And arrays of arrays</div><div class=""> var arrayArrayA = [arrayA] // Array<Array<A>></div><div class=""> arrayArrayA[0][0] = b // OK</div><div class=""> let arrayB = [b] // Array<B></div><div class=""> arrayArrayA[0] = arrayB // OK, works out that an Array<B> is a Array<A></div></div></div></blockquote><div><br class=""></div>There are implicit conversions from Array<T> to Array<U> if T < U, and similarly for Optional, so they’re covariant in this sense (but it’s an explicit runtime conversion behind the scenes).</div><div><br class=""><blockquote type="cite" class=""><div class=""><div class=""><div class=""> </div><div class=""><div class=""> // Covariant homebrew-collections work</div><div class=""> class C<T: AnyObject> { </div><div class=""> var e: T</div><div class=""> init(_ e: T) { self.e = e }</div><div class=""> }</div><div class=""> var cA = C(a) // C<A></div><div class=""> cA.e = b // OK</div></div></div></div></blockquote><div><br class=""></div>This is actually not covariance, you’re just upcasting ‘b’ to ‘a’ before calling the setter for cA.e. ‘cA’ is still a C<A>, not a C<B>.</div><div><br class=""><blockquote type="cite" class=""><div class=""><div class=""><div class=""><div class=""> </div><div class=""> // But not quite for homebrew-collections of homebrew-collections</div><div class=""> var cCA = C(cA) // C<C<A>></div><div class=""> cCA.e.e = b // OK</div><div class=""> let cB = C(b) // C<B></div><div class=""> // cCA.e = cB // Error - cannot work out that a C<B> is a C<A> 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></div></blockquote><div><br class=""></div>The problem is determining if something is safe. For example,</div><div><br class=""></div><div>class Base {}</div><div>class Derived : Base {}</div><div><br class=""></div><div>struct Covariant<T> {</div><div> func returns() -> T { … }</div><div>}</div><div><br class=""></div><div>Here, you would want Covariant<Derived> to be a subtype of Covariant<Base>, because Covariant<Derived>.returns produces a Derived, which is certainly a subtype of Base.</div><div><br class=""></div><div>This is contravariant though:</div><div><br class=""></div><div>struct Contravariant<T> {</div><div> func takes(_: T)</div><div>}</div><div><br class=""></div><div>Contravariant<Base> is now a subtype of Contravariant<Derived>, not the other way around (proof is an exercise for the reader).</div><div><br class=""></div><div>Ok, so that’s all very well and good, and we could in fact infer this from looking at the types of the members. However, if the library author adds new members, or you add new members in an extension, a generic parameter that was previously covariant or contravariant could now become invariant, breaking source compatibility and ABI.</div><div><br class=""></div><div>Also, there is the issue of representation changes. If a concrete type C conforms to a protocol P, then we model C as a subtype of P, but at runtime a conversion is required and the two types have values with different size, etc. I’m not sure how we would model this in general.</div><div><br class=""></div><div>So I’d rather draw a line in the sand and say that Swift generics should never support variance, except for the simple cases of arrays and optionals which are baked into the type checker.</div><div><br class=""></div><div>Slava</div><div><br class=""><blockquote type="cite" class=""><div class=""><div class=""><div class=""><br class=""></div><div class=""> -- 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 <<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>> 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"> 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"><</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">> {</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 = </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 </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"><</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">>… 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 <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"><</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><span style="color:rgb(97,34,174)" class="gmail_msg">UINavigationController</span>> a subtype of </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"><</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">>. </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"><</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">> = </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"><</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">>"</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"><</span><span style="color:rgb(97,34,174);font-variant-ligatures:no-common-ligatures" class="gmail_msg">UINavigationController>”</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 </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"><</span><span style="color:rgb(97,34,174);font-variant-ligatures:no-common-ligatures" class="gmail_msg">UINavigationController> can be cast to 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"><</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">>…</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"><</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">>] = [</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 <<a href="mailto:spestov@apple.com" class="gmail_msg" target="_blank">spestov@apple.com</a>> 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<UINavigationController>’, but you are casting it to ‘Something<UIViewController>’. The two types are not related; in general, if A is a subtype of B, then G<A> is not a subtype of G<B>.<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 <<a href="mailto:swift-users@swift.org" class="gmail_msg" target="_blank">swift-users@swift.org</a>> 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<VC: UIViewController>” 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<UINavigationController> { }<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<UIViewController> 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<UIViewController>) -> Bool<br class="gmail_msg">}<br class="gmail_msg"><br class="gmail_msg">class Something<VC: UIViewController>: 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<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>final internal func addAnything(anything: Something<UIViewController>) -> 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<UINavigationController> { }<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<UIViewController>'<br class="gmail_msg"><br class="gmail_msg">firstThing.addAnything(anything: secondThing as Something<UIViewController>)<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<UIViewController>' 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>
</div></blockquote></div><br class=""></body></html>