<div dir="ltr">On Wed, May 24, 2017 at 3:32 PM, David Sweeris via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</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 style="word-wrap:break-word">So, I’m working on a type, and would like to make it conform to `ExpressibleByArrayLiteral`. The thing is, I don’t actually care what type `Element` is as long as it conforms to `FixedWidthInteger` and `UnsignedInteger`. I tried writing this:<div><div style="margin:0px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)">public</span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)">init</span><span style="font-variant-ligatures:no-common-ligatures"> &lt;U: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)">FixedWidthInteger</span><span style="font-variant-ligatures:no-common-ligatures"> &amp; </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)">UnsignedInteger</span><span style="font-variant-ligatures:no-common-ligatures">&gt; (arrayLiteral elements: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)">U</span><span style="font-variant-ligatures:no-common-ligatures">...) { </span>… }</div></div><div><span style="font-variant-ligatures:no-common-ligatures">But Xcode says my type doesn’t conform to `ExpressibleByArrayLiteral` unless I add an init that takes a concrete type:</span></div><div><span style="font-variant-ligatures:no-common-ligatures"><div style="margin:0px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)">public</span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)">init</span><span style="font-variant-ligatures:no-common-ligatures">(arrayLiteral elements: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)">UInt</span><span style="font-variant-ligatures:no-common-ligatures">...) {</span><font face="Menlo"> </font><font face="Menlo">…</font> }</div><div><span style="font-variant-ligatures:no-common-ligatures"><br></span></div><div><span style="font-variant-ligatures:no-common-ligatures">Does anyone else think the generic init should to be able to satisfy `ExpressibleByArrayLiteral` (especially since `UInt` meets the conformance requirements)?</span></div></span></div></div></blockquote><div><br></div><div>Your type needs to be generic.</div><div><br></div><div>```</div><div><div>struct S&lt;T : UnsignedInteger &amp; FixedWidthInteger&gt; {</div><div>  let x: [T]</div><div>}</div><div><br></div><div>extension S : ExpressibleByArrayLiteral {</div><div>  init(arrayLiteral: T...) {</div><div>    self.x = arrayLiteral</div><div>  }</div><div>}</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 style="word-wrap:break-word"><div><span style="font-variant-ligatures:no-common-ligatures"><div><span style="font-variant-ligatures:no-common-ligatures">I suspect that the compiler is complaining because the generic init function implies that the `Element` associated type is a generic constraint, rather than a concrete type (which maybe makes this related to generic protocols?). I think that’s only an issue because of the current ExpressibleBy*Literal protocols’ reliance on associated types to specify the relevant init’s signature, though. If the protocols (or literal system) could be re-architected so they don&#39;t need those associated types, it might make implementing this easier. I don’t know how much work either approach would be. Nor am I sure if it’d be better for this to be a use-case for another proposal instead of its own thing.</span></div></span></div></div></blockquote><div> </div></div></div></div>