<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 13, 2015, at 3:55 PM, Marc Knaup 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=""><div dir="ltr" class="">Hey guys,<div class=""><br class=""></div><div class="">I'm looking at Swift 3.0's goal to improve generics.</div><div class=""><br class=""></div><div class="">Is there any info yet if and how we will be able to refer to instances of protocols that have associated types?</div></div></div></blockquote><div><br class=""></div>As far as I know, this isn't a solvable problem.</div><div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="">What is the difficulty in supporting this?</div></div></div></blockquote><br class=""></div><div>Here's a simple example:</div><div><br class=""></div><div>protocol P {</div><div>&nbsp; typealias A</div><div>&nbsp; var x: A { get set }</div><div>}</div><div><br class=""></div><div>struct Y : P {</div><div>&nbsp; var x: Int</div><div>}</div><div><br class=""></div><div>struct Z : P {</div><div>&nbsp; var x: String</div><div>}</div><div><br class=""></div><div>func f(p1: P, p2: P) {</div><div>&nbsp; p1.x = p2.x // assigning an Int to a String?</div><div>}</div><div>&nbsp;&nbsp;</div><div><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="">Simple examples:</div><div class=""><font face="monospace, monospace" class="">var list = [Hashable]()</font></div><div class=""><font face="monospace, monospace" class="">var hashable: Hashable = 2</font></div><div class=""><br class=""></div><div class="">Right now all we get is</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">protocol 'Hashable' can only be used as a generic constraint because it has Self or associated type requirements</blockquote></div></div></blockquote></div><div><br class=""></div><div>In this case it's "self requirements" inherited from Equatable that make instances of Hashable impossible.</div><div>That said, providing for sets/dictionaries of heterogeneous values is a problem we're interested in solving in the standard library.</div><br class=""><div class="">
-Dave<div class=""><br class=""></div><br class="Apple-interchange-newline">

</div>
<br class=""></body></html>