<div dir="ltr">







<p class=""><span class="">protocol</span><span class=""> Box: </span><span class="">CustomStringConvertible</span><span class="">, </span><span class="">CustomDebugStringConvertible</span><span class=""> {</span></p>
<p class=""><span class="">    </span></p>
<p class=""><span class="">    </span><span class="">typealias</span><span class=""> FloatLiteralType = Double</span></p>
<p class=""><span class="">    </span><span class="">typealias</span><span class=""> IntegerLiteralType = Int</span></p>
<p class=""><span class="">    </span><span class="">typealias</span><span class=""> BoxType = Any</span></p>
<p class=""><span class="">    </span></p>
<p class=""><span class="">    </span><span class="">var</span><span class=""> value: </span><span class="">BoxType</span><span class=""> { </span><span class="">get</span><span class=""> </span><span class="">set</span><span class=""> }</span></p>
<p class=""><span class="">    </span></p>
<p class=""><span class="">    </span><span class="">init</span><span class="">()</span></p>
<p class=""><span class="">    </span><span class="">init</span><span class="">(</span><span class="">_</span><span class=""> value: </span><span class="">BoxType</span><span class="">)</span></p>
<p class="">}</p>
<p class=""><span class="">extension</span><span class=""> </span><span class="">Box</span><span class=""> </span><span class="">where</span><span class=""> </span><span class="">Self</span><span class="">.BoxType == Double {</span></p>
<p class=""><span class="">    </span></p>
<p class=""><span class="">    </span><span class="">init</span><span class="">(</span><span class="">_</span><span class=""> value: </span><span class="">Double</span><span class="">) {</span></p>
<p class=""><span class="">        </span></p>
<p class=""><span class="">        </span><span class="">self</span><span class="">.</span><span class="">init</span><span class="">()</span></p>
<p class=""><span class="">        </span><span class="">self</span><span class="">.</span><span class="">value</span><span class=""> = value</span></p>
<p class=""><span class="">    }</span></p>
<p class=""><span class="">    </span></p>
<p class=""><span class="">    </span><span class="">init</span><span class="">(</span><span class="">_</span><span class=""> value: </span><span class="">Int</span><span class="">) {</span></p>
<p class=""><span class="">        </span><span class="">self</span><span class="">.</span><span class="">init</span><span class="">()</span></p>
<p class=""><span class="">        </span><span class="">self</span><span class="">.</span><span class="">value</span><span class=""> = </span><span class="">Double</span><span class="">(value)</span></p>
<p class=""><span class="">    }</span></p>
<p class=""><span class="">    </span></p>
<p class=""><span class="">    </span><span class="">init</span><span class="">(</span><span class="">_</span><span class=""> value: </span><span class="">UInt32</span><span class="">) {</span></p>
<p class=""><span class="">        </span><span class="">self</span><span class="">.</span><span class="">init</span><span class="">()</span></p>
<p class=""><span class="">        </span><span class="">self</span><span class="">.</span><span class="">value</span><span class=""> = </span><span class="">Double</span><span class="">(value)</span></p>
<p class=""><span class="">    }</span></p>
<p class=""><span class="">}</span></p><p class=""><span class=""><br></span></p><p class=""><span class=""><br></span></p><p class=""><span class="">Without that last method, Swift tries to give the UInt32 to the Int version of the method which isn&#39;t safe in my eyes and I would have expected a compiler error.</span></p></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jan 6, 2016 at 6:14 PM, Félix Cloutier <span dir="ltr">&lt;<a href="mailto:felixcca@yahoo.ca" target="_blank">felixcca@yahoo.ca</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">I don&#39;t understand. Can you show a code example?<div><div>
<br><span style="color:rgb(0,0,0);font-family:&#39;Lucida Grande&#39;;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;display:inline!important;float:none">Félix</span>
</div>

<br><div><blockquote type="cite"><div><div class="h5"><div>Le 6 janv. 2016 à 13:02:43, James Campbell via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; a écrit :</div><br></div></div><div><div><div class="h5"><div dir="ltr">I have a overloaded method for a protocol that takes an Int or double.<div><br></div><div>I have an issue with swift calling the Int version when passing in a UInt32 . Ideally I would prefer the compiler to detect I am about to do something which will cause an overflow and throw an error.</div><div><br></div><div>I would then have to explicitly add a overloaded UInt32 method or explicitly convert it to Int like so &quot;Int(uintVariable)&quot;.<br><div><div><br></div>-- <br><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div><span style="font-size:16px;line-height:19.2px"></span><span style="font-size:12.8px"> Wizard</span><br></div><div><a href="mailto:james@supmenow.com" target="_blank">james@supmenow.com</a></div><div><a href="tel:%2B44%207523%20279%20698" value="+447523279698" target="_blank">+44 7523 279 698</a></div></div></div></div></div></div>
</div></div></div>
</div></div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=iRI3beHTe3UxYAHTlV3lA38zIPfHMhyuRzgTmGKV6k419Va-2Fjfy307WOceC97TSnJ4yKykvotDhTuWdtGSmuCkzY650M4nROHpKCTmQcDZ02kRdLGOnAQDDmImpHoyttQmzoXSgvw2ZXpGlG2RNVrFaO1Bx6wy76nUr6VThD1LZzzgoOZj9bJN4quck7YFgENkJjy9ruI1FgHPMjI-2BQsWdZHLSKm-2B592tvIuGNC-2F6u4-3D" alt="" width="1" height="1" border="0" style="min-height:1px!important;width:1px!important;border-width:0!important;margin-top:0!important;margin-bottom:0!important;margin-right:0!important;margin-left:0!important;padding-top:0!important;padding-bottom:0!important;padding-right:0!important;padding-left:0!important">
_______________________________________________<br>swift-evolution mailing list<br><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br></div></blockquote></div><br></div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div><span style="font-size:16px;line-height:19.2px"></span><span style="font-size:12.8px"> Wizard</span><br></div><div><a href="mailto:james@supmenow.com" target="_blank">james@supmenow.com</a></div><div>+44 7523 279 698</div></div></div></div></div></div>
</div>