<div dir="ltr"><div class="gmail_default" style="font-family:georgia,serif">Sorry Dave, I didn&#39;t notice that you said in `extension`. I just put the &quot;<span style="font-size:12.800000190734863px;font-family:arial,sans-serif">where Source == Displacement&quot; to the original poster&#39;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">&lt;<a href="mailto:davesweeris@mac.com" target="_blank">davesweeris@mac.com</a>&gt;</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:&#39;Fira Mono&#39;;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&lt;Source, Displacement&gt; {</div><span class=""><div style="margin:0px;line-height:normal;font-family:&#39;Fira Mono&#39;;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:&#39;Fira Mono&#39;;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:&#39;Fira Mono&#39;;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:&#39;Fira Mono&#39;;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:&#39;Fira Mono&#39;;color:rgb(164,176,177);background-color:rgb(0,57,70)">  {</div><div style="margin:0px;line-height:normal;font-family:&#39;Fira Mono&#39;;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:&#39;Fira Mono&#39;;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:&#39;Fira Mono&#39;;color:rgb(164,176,177);background-color:rgb(0,57,70)">  }</div><p style="margin:0px;line-height:normal;font-family:&#39;Fira Mono&#39;;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:&#39;Fira Mono&#39;;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:&#39;Fira Mono&#39;"> </span><span style="color:#7f87cf">DistortedNoise</span><span style="font-size:12px;line-height:normal;font-family:&#39;Fira Mono&#39;"> </span><span style="color:#de5194">where</span><span style="font-size:12px;line-height:normal;font-family:&#39;Fira Mono&#39;"> Source == Displacement {</span></div><span class=""><div style="margin:0px;line-height:normal;font-family:&#39;Fira Mono&#39;;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:&#39;Fira Mono&#39;;color:rgb(164,176,177);background-color:rgb(0,57,70)">  {</div><div style="margin:0px;line-height:normal;font-family:&#39;Fira Mono&#39;;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:&#39;Fira Mono&#39;">    </span><span style="color:#de5194">self</span><span style="font-size:12px;line-height:normal;font-family:&#39;Fira Mono&#39;">.</span><span style="color:#2fafa9">displacement</span><span style="font-size:12px;line-height:normal;font-family:&#39;Fira Mono&#39;"> = source</span></div><div style="margin:0px;line-height:normal;font-family:&#39;Fira Mono&#39;;color:rgb(164,176,177);background-color:rgb(0,57,70)">  }</div><div style="margin:0px;line-height:normal;font-family:&#39;Fira Mono&#39;;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:&#39;Fira Mono&#39;;color:rgb(164,176,177)"> foo = </span><span style="color:#7f87cf">DistortedNoise</span><span style="font-size:12px;line-height:normal;font-family:&#39;Fira Mono&#39;;color:rgb(164,176,177)">(source: </span><span style="color:#e5493d">1</span><span style="font-size:12px;line-height:normal;font-family:&#39;Fira Mono&#39;;color:rgb(164,176,177)">) </span>// DistortedNoise&lt;Int, Int&gt;</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:&#39;Fira Mono&#39;;color:rgb(164,176,177)">.</span>source<span style="font-size:12px;line-height:normal;font-family:&#39;Fira Mono&#39;;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:&#39;Fira Mono&#39;;color:rgb(164,176,177)">.</span>displacement<span style="font-size:12px;line-height:normal;font-family:&#39;Fira Mono&#39;;color:rgb(164,176,177)"> </span><span style="color:#6a8188">// 1</span></div><div><span style="color:#6a8188"><br></span></div><div><div>That&#39;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 &quot;<span style="color:rgb(69,69,69);font-family:&#39;Helvetica Neue&#39;">__lldb_expr_2.DistortedNoise&lt;<wbr>Int, Int&gt;&quot; instead of just &quot;</span><span style="color:rgb(69,69,69);font-family:&#39;Helvetica Neue&#39;">DistortedNoise&lt;Int, Int&gt;</span><span style="color:rgb(69,69,69);font-family:&#39;Helvetica Neue&#39;">&quot;, but that&#39;s just a more... I think the word is &quot;qualified&quot;... name for the same thing.</span></div><div><span style="color:rgb(69,69,69);font-family:&#39;Helvetica Neue&#39;"><br></span></div><div><span style="color:rgb(69,69,69);font-family:&#39;Helvetica Neue&#39;">- 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 &lt;<a href="mailto:owenzx@gmail.com" target="_blank">owenzx@gmail.com</a>&gt; 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.  &quot;error: same-type requirement makes generic parameters &#39;Source&#39; and &#39;Displacement&#39; equivalent&quot;.</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">&lt;<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>&gt;</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 &quot;where Source == Displacement&quot;<br>
<div class="m_2062407511329566562HOEnZb"><div class="m_2062407511329566562h5"><br>
&gt; On Jul 8, 2017, at 21:06, Taylor Swift via swift-users &lt;<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>&gt; wrote:<br>
&gt;<br>
&gt; I have a type like<br>
&gt;<br>
&gt; struct DistortedNoise&lt;Source, Displacement&gt; where Source:Noise, Displacement:Noise<br>
&gt; {<br>
&gt;     let source:Source,<br>
&gt;         displacement:Displacement<br>
&gt;<br>
&gt;     init(source:Source, displacement:Displacement)<br>
&gt;     {<br>
&gt;         self.source       = source<br>
&gt;         self.displacement = displacement<br>
&gt;     }<br>
&gt;<br>
&gt;     init(source:Source)<br>
&gt;     {<br>
&gt;         self.source       = source<br>
&gt;         self.displacement = source<br>
&gt;     }<br>
&gt; }<br>
&gt;<br>
&gt; and I get the error<br>
&gt;<br>
&gt; Compile Swift Module &#39;Noise&#39; (5 sources)<br>
&gt; /home/taylor/noise/sources/noi<wbr>se/noise.swift:576:29: error: &#39;Source&#39; is not convertible to &#39;Displacement&#39;<br>
&gt;         self.displacement = source<br>
&gt;                             ^~~~~~<br>
&gt;<br>
&gt; How do I tell Swift that I want the same type fulfilling both Source and Displacement?<br>
&gt;<br>
</div></div><div class="m_2062407511329566562HOEnZb"><div class="m_2062407511329566562h5">&gt; ______________________________<wbr>_________________<br>
&gt; swift-users mailing list<br>
&gt; <a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a><br>
&gt; <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>