<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>Oh, I hate that error! If there was ever a time I've wanted to have a conversation with the compiler... "yes, mr compiler, I know the same type requirement makes them equivalent; that's why I wrote it! Please compile anyway."<br><br>Which version of the compiler/language are you using?<br><br>Sent from my iPhone</div><div><br>On Jul 8, 2017, at 21:39, Zhao Xin <<a href="mailto:owenzx@gmail.com">owenzx@gmail.com</a>> wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr"><div class="gmail_default" style="font-family:georgia,serif">No, David, it is now allowed. "error: same-type requirement makes generic parameters 'Source' and 'Displacement' equivalent".</div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default" style="font-family:georgia,serif">Zhao Xin</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Jul 9, 2017 at 12:35 PM, David Sweeris via swift-users <span dir="ltr"><<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">You could try putting that init in an extension "where Source == Displacement"<br>
<div class="HOEnZb"><div class="h5"><br>
> On Jul 8, 2017, at 21:06, Taylor Swift via swift-users <<a href="mailto:swift-users@swift.org">swift-users@swift.org</a>> wrote:<br>
><br>
> I have a type like<br>
><br>
> struct DistortedNoise<Source, Displacement> where Source:Noise, Displacement:Noise<br>
> {<br>
> let source:Source,<br>
> displacement:Displacement<br>
><br>
> init(source:Source, displacement:Displacement)<br>
> {<br>
> self.source = source<br>
> self.displacement = displacement<br>
> }<br>
><br>
> init(source:Source)<br>
> {<br>
> self.source = source<br>
> self.displacement = source<br>
> }<br>
> }<br>
><br>
> and I get the error<br>
><br>
> Compile Swift Module 'Noise' (5 sources)<br>
> /home/taylor/noise/sources/<wbr>noise/noise.swift:576:29: error: 'Source' is not convertible to 'Displacement'<br>
> self.displacement = source<br>
> ^~~~~~<br>
><br>
> How do I tell Swift that I want the same type fulfilling both Source and Displacement?<br>
><br>
</div></div><div class="HOEnZb"><div class="h5">> ______________________________<wbr>_________________<br>
> swift-users mailing list<br>
> <a href="mailto:swift-users@swift.org">swift-users@swift.org</a><br>
> <a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-users</a><br>
______________________________<wbr>_________________<br>
swift-users mailing list<br>
<a href="mailto:swift-users@swift.org">swift-users@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-users</a><br>
</div></div></blockquote></div><br></div>
</div></blockquote></body></html>