<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">I either don't understand or can't reproduce the issue. This code:</div><div class=""><br class=""></div><div class=""></div><blockquote type="cite" class=""><div class="">class Box {</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>let value: Int</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span></div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>init(value: Int) {</div><div class=""><span class="Apple-tab-span" style="white-space:pre">                </span>self.value = value</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div class="">}</div><div class=""><br class=""></div><div class="">let test: UInt32 = 4</div><div class="">let box = Box(value: test)</div></blockquote><div class=""><br class=""></div><div class="">does not compile ("foo.swift:10:22: error: cannot convert value of type 'UInt32' to expected argument type 'Int'").</div><div class="">
<br class="Apple-interchange-newline"><span style="color: rgb(0, 0, 0); font-family: 'Lucida Grande'; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none;" class="">Félix</span>
</div>
<br class=""><div><blockquote type="cite" class=""><div class="">Le 6 janv. 2016 à 13:17:03, James Campbell <<a href="mailto:james@supmenow.com" class="">james@supmenow.com</a>> a écrit :</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" style="font-family: LucidaGrande; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><p class=""><span class="">protocol</span><span class=""><span class="Apple-converted-space"> </span>Box:<span class="Apple-converted-space"> </span></span><span class="">CustomStringConvertible</span><span class="">,<span class="Apple-converted-space"> </span></span><span class="">CustomDebugStringConvertible</span><span class=""><span class="Apple-converted-space"> </span>{</span></p><div class=""><span class=""> </span><br class="webkit-block-placeholder"></div><p class=""><span class=""> <span class="Apple-converted-space"> </span></span><span class="">typealias</span><span class=""><span class="Apple-converted-space"> </span>FloatLiteralType = Double</span></p><p class=""><span class=""> <span class="Apple-converted-space"> </span></span><span class="">typealias</span><span class=""><span class="Apple-converted-space"> </span>IntegerLiteralType = Int</span></p><p class=""><span class=""> <span class="Apple-converted-space"> </span></span><span class="">typealias</span><span class=""><span class="Apple-converted-space"> </span>BoxType = Any</span></p><div class=""><span class=""> </span><br class="webkit-block-placeholder"></div><p class=""><span class=""> <span class="Apple-converted-space"> </span></span><span class="">var</span><span class=""><span class="Apple-converted-space"> </span>value:<span class="Apple-converted-space"> </span></span><span class="">BoxType</span><span class=""><span class="Apple-converted-space"> </span>{<span class="Apple-converted-space"> </span></span><span class="">get</span><span class=""><span class="Apple-converted-space"> </span></span><span class="">set</span><span class=""><span class="Apple-converted-space"> </span>}</span></p><div class=""><span class=""> </span><br class="webkit-block-placeholder"></div><p class=""><span class=""> <span class="Apple-converted-space"> </span></span><span class="">init</span><span class="">()</span></p><p class=""><span class=""> <span class="Apple-converted-space"> </span></span><span class="">init</span><span class="">(</span><span class="">_</span><span class=""><span class="Apple-converted-space"> </span>value:<span class="Apple-converted-space"> </span></span><span class="">BoxType</span><span class="">)</span></p><p class="">}</p><p class=""><span class="">extension</span><span class=""><span class="Apple-converted-space"> </span></span><span class="">Box</span><span class=""><span class="Apple-converted-space"> </span></span><span class="">where</span><span class=""><span class="Apple-converted-space"> </span></span><span class="">Self</span><span class="">.BoxType == Double {</span></p><div class=""><span class=""> </span><br class="webkit-block-placeholder"></div><p class=""><span class=""> <span class="Apple-converted-space"> </span></span><span class="">init</span><span class="">(</span><span class="">_</span><span class=""><span class="Apple-converted-space"> </span>value:<span class="Apple-converted-space"> </span></span><span class="">Double</span><span class="">) {</span></p><div class=""><span class=""> </span><br class="webkit-block-placeholder"></div><p class=""><span class=""> <span class="Apple-converted-space"> </span></span><span class="">self</span><span class="">.</span><span class="">init</span><span class="">()</span></p><p class=""><span class=""> <span class="Apple-converted-space"> </span></span><span class="">self</span><span class="">.</span><span class="">value</span><span class=""><span class="Apple-converted-space"> </span>= value</span></p><p class=""><span class=""> }</span></p><div class=""><span class=""> </span><br class="webkit-block-placeholder"></div><p class=""><span class=""> <span class="Apple-converted-space"> </span></span><span class="">init</span><span class="">(</span><span class="">_</span><span class=""><span class="Apple-converted-space"> </span>value:<span class="Apple-converted-space"> </span></span><span class="">Int</span><span class="">) {</span></p><p class=""><span class=""> <span class="Apple-converted-space"> </span></span><span class="">self</span><span class="">.</span><span class="">init</span><span class="">()</span></p><p class=""><span class=""> <span class="Apple-converted-space"> </span></span><span class="">self</span><span class="">.</span><span class="">value</span><span class=""><span class="Apple-converted-space"> </span>=<span class="Apple-converted-space"> </span></span><span class="">Double</span><span class="">(value)</span></p><p class=""><span class=""> }</span></p><div class=""><span class=""> </span><br class="webkit-block-placeholder"></div><p class=""><span class=""> <span class="Apple-converted-space"> </span></span><span class="">init</span><span class="">(</span><span class="">_</span><span class=""><span class="Apple-converted-space"> </span>value:<span class="Apple-converted-space"> </span></span><span class="">UInt32</span><span class="">) {</span></p><p class=""><span class=""> <span class="Apple-converted-space"> </span></span><span class="">self</span><span class="">.</span><span class="">init</span><span class="">()</span></p><p class=""><span class=""> <span class="Apple-converted-space"> </span></span><span class="">self</span><span class="">.</span><span class="">value</span><span class=""><span class="Apple-converted-space"> </span>=<span class="Apple-converted-space"> </span></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 class=""></span></p><p class=""><span class=""><br class=""></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't safe in my eyes and I would have expected a compiler error.</span></p></div><div class="gmail_extra" style="font-family: LucidaGrande; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class=""><div class="gmail_quote">On Wed, Jan 6, 2016 at 6:14 PM, Félix Cloutier<span class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:felixcca@yahoo.ca" target="_blank" class="">felixcca@yahoo.ca</a>></span><span class="Apple-converted-space"> </span>wrote:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div style="word-wrap: break-word;" class="">I don't understand. Can you show a code example?<div class=""><div class=""><br class=""><span style="font-family: 'Lucida Grande'; 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; float: none; display: inline !important;" class="">Félix</span></div><br class=""><div class=""><blockquote type="cite" class=""><div class=""><div class="h5"><div class="">Le 6 janv. 2016 à 13:02:43, James Campbell via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>> a écrit :</div><br class=""></div></div><div class=""><div class=""><div class="h5"><div dir="ltr" class="">I have a overloaded method for a protocol that takes an Int or double.<div class=""><br class=""></div><div class="">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 class=""><br class=""></div><div class="">I would then have to explicitly add a overloaded UInt32 method or explicitly convert it to Int like so "Int(uintVariable)".<br class=""><div class=""><div class=""><br class=""></div>--<span class="Apple-converted-space"> </span><br class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div dir="ltr" class=""><div class=""><span style="font-size: 16px; line-height: 19.2px;" class=""></span><span style="font-size: 12.8px;" class=""> Wizard</span><br class=""></div><div class=""><a href="mailto:james@supmenow.com" target="_blank" class="">james@supmenow.com</a></div><div class=""><a href="tel:%2B44%207523%20279%20698" value="+447523279698" target="_blank" class="">+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: 0px !important; margin: 0px !important; padding: 0px !important;" class=""><span class="Apple-converted-space"> </span>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></blockquote></div><br class=""></div></div></blockquote></div><br class=""><br clear="all" class=""><div class=""><br class=""></div>--<span class="Apple-converted-space"> </span><br class=""><div class="gmail_signature"><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div dir="ltr" class=""><div class=""><span style="font-size: 16px; line-height: 19.2px;" class=""></span><span style="font-size: 12.8px;" class=""> Wizard</span><br class=""></div><div class=""><a href="mailto:james@supmenow.com" target="_blank" class="">james@supmenow.com</a></div><div class="">+44 7523 279 698</div></div></div></div></div></div></div></div></blockquote></div><br class=""></body></html>