<div dir="ltr"><div class="gmail_default" style="font-family:georgia,serif">Sorry Dave, I didn't notice that you said in `extension`. I just put the "<span style="font-size:12.800000190734863px;font-family:arial,sans-serif">where Source == Displacement" to the original poster's code and the error showed. My bad.</span></div><div class="gmail_default" style="font-family:georgia,serif"><span style="font-size:12.800000190734863px;font-family:arial,sans-serif"><br></span></div><div class="gmail_default" style="font-family:georgia,serif"><span style="font-size:12.800000190734863px;font-family:arial,sans-serif">Zhao Xin</span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Jul 9, 2017 at 1:56 PM, David Sweeris <span dir="ltr"><<a href="mailto:davesweeris@mac.com" target="_blank">davesweeris@mac.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Hmm... I just tried it in a playground, and it works:<div><div style="margin:0px;line-height:normal;font-family:'Fira Mono';color:rgb(164,176,177);background-color:rgb(0,57,70)"><span style="font-size:11px;line-height:normal;font-family:Menlo;color:rgb(222,81,148)">struct</span> DistortedNoise<Source, Displacement> {</div><span class=""><div style="margin:0px;line-height:normal;font-family:'Fira Mono';color:rgb(164,176,177);background-color:rgb(0,57,70)"> <span style="font-size:11px;line-height:normal;font-family:Menlo;color:rgb(222,81,148)">let</span> source:<span style="font-size:11px;line-height:normal;font-family:Menlo;color:rgb(127,135,207)">Source</span>,</div><div style="margin:0px;line-height:normal;font-family:'Fira Mono';color:rgb(164,176,177);background-color:rgb(0,57,70)"> displacement:<span style="font-size:11px;line-height:normal;font-family:Menlo;color:rgb(127,135,207)">Displacement</span></div><p style="margin:0px;line-height:normal;font-family:'Fira Mono';color:rgb(164,176,177);background-color:rgb(0,57,70);min-height:14px"> <br class="m_2062407511329566562webkit-block-placeholder"></p><div style="margin:0px;line-height:normal;font-family:'Fira Mono';color:rgb(164,176,177);background-color:rgb(0,57,70)"> <span style="font-size:11px;line-height:normal;font-family:Menlo;color:rgb(222,81,148)">init</span>(source:<span style="font-size:11px;line-height:normal;font-family:Menlo;color:rgb(127,135,207)">Source</span>, displacement:<span style="font-size:11px;line-height:normal;font-family:Menlo;color:rgb(127,135,207)">Displacement</span>)</div><div style="margin:0px;line-height:normal;font-family:'Fira Mono';color:rgb(164,176,177);background-color:rgb(0,57,70)"> {</div><div style="margin:0px;line-height:normal;font-family:'Fira Mono';color:rgb(164,176,177);background-color:rgb(0,57,70)"> <span style="font-size:11px;line-height:normal;font-family:Menlo;color:rgb(222,81,148)">self</span>.<span style="font-size:11px;line-height:normal;font-family:Menlo;color:rgb(47,175,169)">source</span> = source</div><div style="margin:0px;line-height:normal;font-family:'Fira Mono';color:rgb(164,176,177);background-color:rgb(0,57,70)"> <span style="font-size:11px;line-height:normal;font-family:Menlo;color:rgb(222,81,148)">self</span>.<span style="font-size:11px;line-height:normal;font-family:Menlo;color:rgb(47,175,169)">displacement</span> = displacement</div><div style="margin:0px;line-height:normal;font-family:'Fira Mono';color:rgb(164,176,177);background-color:rgb(0,57,70)"> }</div><p style="margin:0px;line-height:normal;font-family:'Fira Mono';color:rgb(164,176,177);background-color:rgb(0,57,70);min-height:14px"> <br class="m_2062407511329566562webkit-block-placeholder"></p><div style="margin:0px;line-height:normal;font-family:'Fira Mono';color:rgb(164,176,177);background-color:rgb(0,57,70)">}</div></span><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(164,176,177);background-color:rgb(0,57,70)"><span style="color:#de5194">extension</span><span style="font-size:12px;line-height:normal;font-family:'Fira Mono'"> </span><span style="color:#7f87cf">DistortedNoise</span><span style="font-size:12px;line-height:normal;font-family:'Fira Mono'"> </span><span style="color:#de5194">where</span><span style="font-size:12px;line-height:normal;font-family:'Fira Mono'"> Source == Displacement {</span></div><span class=""><div style="margin:0px;line-height:normal;font-family:'Fira Mono';color:rgb(164,176,177);background-color:rgb(0,57,70)"> <span style="font-size:11px;line-height:normal;font-family:Menlo;color:rgb(222,81,148)">init</span>(source:<span style="font-size:11px;line-height:normal;font-family:Menlo;color:rgb(127,135,207)">Source</span>)</div><div style="margin:0px;line-height:normal;font-family:'Fira Mono';color:rgb(164,176,177);background-color:rgb(0,57,70)"> {</div><div style="margin:0px;line-height:normal;font-family:'Fira Mono';color:rgb(164,176,177);background-color:rgb(0,57,70)"> <span style="font-size:11px;line-height:normal;font-family:Menlo;color:rgb(222,81,148)">self</span>.<span style="font-size:11px;line-height:normal;font-family:Menlo;color:rgb(47,175,169)">source</span> = source</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(164,176,177);background-color:rgb(0,57,70)"><span style="font-size:12px;line-height:normal;font-family:'Fira Mono'"> </span><span style="color:#de5194">self</span><span style="font-size:12px;line-height:normal;font-family:'Fira Mono'">.</span><span style="color:#2fafa9">displacement</span><span style="font-size:12px;line-height:normal;font-family:'Fira Mono'"> = source</span></div><div style="margin:0px;line-height:normal;font-family:'Fira Mono';color:rgb(164,176,177);background-color:rgb(0,57,70)"> }</div><div style="margin:0px;line-height:normal;font-family:'Fira Mono';color:rgb(164,176,177);background-color:rgb(0,57,70)">}</div></span><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(106,129,136);background-color:rgb(0,57,70)"><span style="color:#de5194">let</span><span style="font-size:12px;line-height:normal;font-family:'Fira Mono';color:rgb(164,176,177)"> foo = </span><span style="color:#7f87cf">DistortedNoise</span><span style="font-size:12px;line-height:normal;font-family:'Fira Mono';color:rgb(164,176,177)">(source: </span><span style="color:#e5493d">1</span><span style="font-size:12px;line-height:normal;font-family:'Fira Mono';color:rgb(164,176,177)">) </span>// DistortedNoise<Int, Int></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(47,175,169);background-color:rgb(0,57,70)">foo<span style="font-size:12px;line-height:normal;font-family:'Fira Mono';color:rgb(164,176,177)">.</span>source<span style="font-size:12px;line-height:normal;font-family:'Fira Mono';color:rgb(164,176,177)"> </span><span style="color:#6a8188">// 1</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(47,175,169);background-color:rgb(0,57,70)">foo<span style="font-size:12px;line-height:normal;font-family:'Fira Mono';color:rgb(164,176,177)">.</span>displacement<span style="font-size:12px;line-height:normal;font-family:'Fira Mono';color:rgb(164,176,177)"> </span><span style="color:#6a8188">// 1</span></div><div><span style="color:#6a8188"><br></span></div><div><div>That's with Xcode 9b2, using the default Xcode 9.0 toolchain. With Xcode 8.3.3 and its default toolchain, the `let foo = ...` line outputs "<span style="color:rgb(69,69,69);font-family:'Helvetica Neue'">__lldb_expr_2.DistortedNoise<<wbr>Int, Int>" instead of just "</span><span style="color:rgb(69,69,69);font-family:'Helvetica Neue'">DistortedNoise<Int, Int></span><span style="color:rgb(69,69,69);font-family:'Helvetica Neue'">", but that's just a more... I think the word is "qualified"... name for the same thing.</span></div><div><span style="color:rgb(69,69,69);font-family:'Helvetica Neue'"><br></span></div><div><span style="color:rgb(69,69,69);font-family:'Helvetica Neue'">- Dave Sweeris</span></div><div><div class="h5"><div><br></div><div><br></div><div><blockquote type="cite"><div>On Jul 8, 2017, at 9:39 PM, Zhao Xin <<a href="mailto:owenzx@gmail.com" target="_blank">owenzx@gmail.com</a>> wrote:</div><br class="m_2062407511329566562Apple-interchange-newline"><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="m_2062407511329566562HOEnZb"><div class="m_2062407511329566562h5"><br>
> On Jul 8, 2017, at 21:06, Taylor Swift via swift-users <<a href="mailto:swift-users@swift.org" target="_blank">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/noi<wbr>se/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="m_2062407511329566562HOEnZb"><div class="m_2062407511329566562h5">> ______________________________<wbr>_________________<br>
> swift-users mailing list<br>
> <a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a><br>
> <a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank">https://lists.swift.org/mailma<wbr>n/listinfo/swift-users</a><br>
______________________________<wbr>_________________<br>
swift-users mailing list<br>
<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank">https://lists.swift.org/mailma<wbr>n/listinfo/swift-users</a><br>
</div></div></blockquote></div><br></div>
</div></blockquote></div><br></div></div></div></div></div></blockquote></div><br></div>