<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="gmail_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>