When you write `associatedtype P = Q`, you are not constraining P but providing a default value. This is one reason why Swift 3 adopted associatedtype instead of typealias inside protocols.<br><br>You can write this:<br><br>```<br>protocol R {<br>        typealias Q = Int<br>}<br><br>struct S : R {<br>        <br>}<br><br>let foo: R = S()<br>```<br><br>You are correct that, if R refined a protocol P with an associated type requirement Q, the typealias in R does not get rid of the associated type requirement. This is not a bug.<br><br>Consider: any method requirements on P can require a return value of P.Q. Conforming types such as S can implement them even if P provides a default implementation, and they may do so in a way that causes P.Q to be a different type than R.Q.<br><div class="gmail_quote"><div dir="ltr">On Mon, Apr 24, 2017 at 14:44 Austin Feight via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>The following code won't compile for reasons we're familiar with:</div><div><pre><code>protocol Value {
associatedType ValueType
var value: ValueType { get set }
}
struct ValueHolder {
var value: Value // Protocol 'Value' can only be used as a generic constraint because it has Self or associated type requirements
}</code></pre></div><div>But then when I make that associated type concrete in a more sub-protocol, the compiler still complains, even when it should no longer have associated type requirements, because ValueType can only be Int.</div><div><pre><code>protocol IntValue: Value {
associatedType ValueType = Int
var value: Int { get set }
}
struct ValueHolder {
var value: IntValue // Protocol 'IntValue' can only be used as a generic constraint because it has Self or associated type requirements
}</code>
</pre></div><div>or at least - that's what I'm trying to achieve with `associatedType ValueType = Int`. Similarly I tried `typealias ValueType = Int`, with the same result.<br></div><div><br></div><div>Would this be considered a compiler bug? Or is IntValue's ValueType shadowing Value's ValueType, and they're both still independent? I don't believe the latter case is correct because even when the original declaration ValueType is concrete, the compiler still complains:</div><div><div><pre><code>protocol IntValue {
associatedType ValueType = Int
var value: Int { get set }
}
struct ValueHolder {
var value: IntValue // Protocol 'IntValue' can only be used as a generic constraint because it has Self or associated type requirements
}</code></pre></div></div><div>Trying to figure out where this proposal would fall, or if it's been discussed already - I wasn't able to find anything similar.</div><div><br></div><div><br></div>Cheers,<br clear="all"><div><div class="m_4373605877271172234gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div style="color:rgb(0,0,0);font-family:helvetica;font-size:12px"><div dir="ltr" style="font-size:12.8px"><div dir="ltr" style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px"><font face="arial,helvetica,sans-serif" color="#000000" style="font-size:12.8px"><b>Austin Feight </b>|<b> </b>Chief Shipping Officer</font></div><div dir="ltr" style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px"><font color="#000000" face="arial, helvetica, sans-serif"><br></font></div><div dir="ltr" style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small"><font color="#000000" face="arial, helvetica, sans-serif" style="font-size:12.8px"><img src="https://docs.google.com/uc?export=download&id=0B4l6EHVu_9V1bXE4ZTd3MWY3bmc&revid=0B4l6EHVu_9V1YTdNenBVcnpZTGVIdUlJS0M3Q3BSR1hQSFJvPQ"><br></font><div><div style="font-size:12.8px"><span style="color:rgb(102,102,102);font-size:12.8px;font-family:arial,helvetica,sans-serif">150 E. 52nd Street, 22nd Floor, New York, NY 10022</span></div><div><span style="border-collapse:collapse"><font color="#999999" face="Tahoma"><span style="font-size:12px"><a href="http://www.coatchex.com/" style="color:rgb(17,85,204)" target="_blank">www.chexology.com</a> | <a href="http://www.austindfeight.com" style="color:rgb(17,85,204)" target="_blank">www.austindfeight.com</a></span></font></span></div></div></div></div></div></div></div></div></div></div></div></div></div>
</div>
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</blockquote></div>