<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hmm... I just tried it in a playground, and it works:<div class=""><div style="margin: 0px; line-height: normal; font-family: 'Fira Mono'; color: rgb(164, 176, 177); background-color: rgb(0, 57, 70);" class=""><span style="font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(222, 81, 148);" class="">struct</span> DistortedNoise<Source, Displacement> {</div><div style="margin: 0px; line-height: normal; font-family: 'Fira Mono'; color: rgb(164, 176, 177); background-color: rgb(0, 57, 70);" class=""> <span style="font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(222, 81, 148);" class="">let</span> source:<span style="font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(127, 135, 207);" class="">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);" class=""> displacement:<span style="font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(127, 135, 207);" class="">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;" class=""> <br class="webkit-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);" class=""> <span style="font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(222, 81, 148);" class="">init</span>(source:<span style="font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(127, 135, 207);" class="">Source</span>, displacement:<span style="font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(127, 135, 207);" class="">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);" class=""> {</div><div style="margin: 0px; line-height: normal; font-family: 'Fira Mono'; color: rgb(164, 176, 177); background-color: rgb(0, 57, 70);" class=""> <span style="font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(222, 81, 148);" class="">self</span>.<span style="font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(47, 175, 169);" class="">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);" class=""> <span style="font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(222, 81, 148);" class="">self</span>.<span style="font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(47, 175, 169);" class="">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);" class=""> }</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;" class=""> <br class="webkit-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);" class="">}</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);" class=""><span style="color: #de5194" class="">extension</span><span style="font-size: 12px; line-height: normal; font-family: 'Fira Mono';" class=""> </span><span style="color: #7f87cf" class="">DistortedNoise</span><span style="font-size: 12px; line-height: normal; font-family: 'Fira Mono';" class=""> </span><span style="color: #de5194" class="">where</span><span style="font-size: 12px; line-height: normal; font-family: 'Fira Mono';" class=""> Source == 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);" class=""> <span style="font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(222, 81, 148);" class="">init</span>(source:<span style="font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(127, 135, 207);" class="">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);" class=""> {</div><div style="margin: 0px; line-height: normal; font-family: 'Fira Mono'; color: rgb(164, 176, 177); background-color: rgb(0, 57, 70);" class=""> <span style="font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(222, 81, 148);" class="">self</span>.<span style="font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(47, 175, 169);" class="">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);" class=""><span style="font-size: 12px; line-height: normal; font-family: 'Fira Mono';" class=""> </span><span style="color: #de5194" class="">self</span><span style="font-size: 12px; line-height: normal; font-family: 'Fira Mono';" class="">.</span><span style="color: #2fafa9" class="">displacement</span><span style="font-size: 12px; line-height: normal; font-family: 'Fira Mono';" class=""> = 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);" class=""> }</div><div style="margin: 0px; line-height: normal; font-family: 'Fira Mono'; color: rgb(164, 176, 177); background-color: rgb(0, 57, 70);" class="">}</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(106, 129, 136); background-color: rgb(0, 57, 70);" class=""><span style="color: #de5194" class="">let</span><span style="font-size: 12px; line-height: normal; font-family: 'Fira Mono'; color: rgb(164, 176, 177);" class=""> foo = </span><span style="color: #7f87cf" class="">DistortedNoise</span><span style="font-size: 12px; line-height: normal; font-family: 'Fira Mono'; color: rgb(164, 176, 177);" class="">(source: </span><span style="color: #e5493d" class="">1</span><span style="font-size: 12px; line-height: normal; font-family: 'Fira Mono'; color: rgb(164, 176, 177);" class="">) </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);" class="">foo<span style="font-size: 12px; line-height: normal; font-family: 'Fira Mono'; color: rgb(164, 176, 177);" class="">.</span>source<span style="font-size: 12px; line-height: normal; font-family: 'Fira Mono'; color: rgb(164, 176, 177);" class=""> </span><span style="color: #6a8188" class="">// 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);" class="">foo<span style="font-size: 12px; line-height: normal; font-family: 'Fira Mono'; color: rgb(164, 176, 177);" class="">.</span>displacement<span style="font-size: 12px; line-height: normal; font-family: 'Fira Mono'; color: rgb(164, 176, 177);" class=""> </span><span style="color: #6a8188" class="">// 1</span></div><div class=""><span style="color: #6a8188" class=""><br class=""></span></div><div class=""><div class="">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';" class="">__lldb_expr_2.DistortedNoise<Int, Int>" instead of just "</span><span style="color: rgb(69, 69, 69); font-family: 'Helvetica Neue';" class="">DistortedNoise<Int, Int></span><span style="color: rgb(69, 69, 69); font-family: 'Helvetica Neue';" class="">", but that's just a more... I think the word is "qualified"... name for the same thing.</span></div><div class=""><span style="color: rgb(69, 69, 69); font-family: 'Helvetica Neue';" class=""><br class=""></span></div><div class=""><span style="color: rgb(69, 69, 69); font-family: 'Helvetica Neue';" class="">- Dave Sweeris</span></div><div class=""><br class=""></div><div class=""><br class=""></div><div><blockquote type="cite" class=""><div class="">On Jul 8, 2017, at 9:39 PM, Zhao Xin <<a href="mailto:owenzx@gmail.com" class="">owenzx@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><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 class=""></div><div class="gmail_default" style="font-family:georgia,serif">Zhao Xin</div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Sun, Jul 9, 2017 at 12:35 PM, David Sweeris via swift-users <span dir="ltr" class=""><<a href="mailto:swift-users@swift.org" target="_blank" class="">swift-users@swift.org</a>></span> wrote:<br class=""><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 class="">
<div class="HOEnZb"><div class="h5"><br class="">
> On Jul 8, 2017, at 21:06, Taylor Swift via swift-users <<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>> wrote:<br class="">
><br class="">
> I have a type like<br class="">
><br class="">
> struct DistortedNoise<Source, Displacement> where Source:Noise, Displacement:Noise<br class="">
> {<br class="">
> let source:Source,<br class="">
> displacement:Displacement<br class="">
><br class="">
> init(source:Source, displacement:Displacement)<br class="">
> {<br class="">
> self.source = source<br class="">
> self.displacement = displacement<br class="">
> }<br class="">
><br class="">
> init(source:Source)<br class="">
> {<br class="">
> self.source = source<br class="">
> self.displacement = source<br class="">
> }<br class="">
> }<br class="">
><br class="">
> and I get the error<br class="">
><br class="">
> Compile Swift Module 'Noise' (5 sources)<br class="">
> /home/taylor/noise/sources/<wbr class="">noise/noise.swift:576:29: error: 'Source' is not convertible to 'Displacement'<br class="">
> self.displacement = source<br class="">
> ^~~~~~<br class="">
><br class="">
> How do I tell Swift that I want the same type fulfilling both Source and Displacement?<br class="">
><br class="">
</div></div><div class="HOEnZb"><div class="h5">> ______________________________<wbr class="">_________________<br class="">
> swift-users mailing list<br class="">
> <a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class="">
> <a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank" class="">https://lists.swift.org/<wbr class="">mailman/listinfo/swift-users</a><br class="">
______________________________<wbr class="">_________________<br class="">
swift-users mailing list<br class="">
<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank" class="">https://lists.swift.org/<wbr class="">mailman/listinfo/swift-users</a><br class="">
</div></div></blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></div></div></body></html>