<div dir="ltr">On Sat, Jun 24, 2017 at 12:09 PM, David Sweeris <span dir="ltr"><<a href="mailto:davesweeris@mac.com" target="_blank">davesweeris@mac.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="auto"><div>Would that even compile? I thought I'd remembered getting an "illegal redefinition of T" or some such error, but maybe I'm misremembering (plus, I haven't tried in a really long time).</div></div></blockquote><div><br></div><div>There is no redefinition; it's just simple shadowing.</div><div><br></div><div>```</div><div><div>protocol P {</div><div> associatedtype T</div><div> func foo() -> T</div><div>}</div><div><br></div><div>struct S<T> : P {</div><div> func foo() -> Int {</div><div> return 42</div><div> }</div><div> func bar(_ x: T) -> T {</div><div> return x</div><div> }</div><div>}</div><div><br></div><div>S<String>().foo() // P.T is Int</div><div>S<String>().bar("42") // S.T is String</div></div><div>```</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="auto"><div id="gmail-m_-8044135647644333123AppleMailSignature">- Dave Sweeris </div><div><div class="gmail-h5"><div id="gmail-m_-8044135647644333123AppleMailSignature"><br></div><div>On Jun 24, 2017, at 08:48, Xiaodi Wu <<a href="mailto:xiaodi.wu@gmail.com" target="_blank">xiaodi.wu@gmail.com</a>> wrote:<br><br></div><blockquote type="cite"><div>For every Bar.T that is currently distinct from Foo.T, this would be source-breaking.<br><div class="gmail_quote"><div dir="ltr">On Sat, Jun 24, 2017 at 01:51 David Sweeris via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><br>
> On Jun 23, 2017, at 5:28 PM, David Moore via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:<br>
><br>
> I do indeed have quite a few real examples of this, such prompted me to bring this up. I think this could be done without any impact to existing code, but it would require some type of keyword. Take the following as a possible prototype.<br>
><br>
> protocol Foo {<br>
> associatedtype T<br>
> }<br>
><br>
> struct Bar<T> : Foo {<br>
> keyword typealias T // Or really any other syntactical implementation.<br>
> }<br>
><br>
> With an opt-in method we could implement this without affecting existing code, thereby making this more viable. I will send some examples later.<br>
<br>
At one point there was talk of just having generic parameters automatically becoming typealiases:<br>
struct Bar<T> : Foo {<br>
// `T` is automatically an implicit typealias for, well, `T`<br>
}<br>
<br>
Dunno if that’s still the plan (or to what degree it ever was), but it’d work for me. I don’t even think it’d break source compatibility (though it may make a lot of typealiases unneeded.<br>
<br>
- Dave Sweeris<br>
______________________________<wbr>_________________<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/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br>
</blockquote></div>
</div></blockquote></div></div></div></blockquote></div><br></div></div>