<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On Sep 12, 2016, at 3:39 PM, Douglas Gregor &lt;<a href="mailto:dgregor@apple.com" class="">dgregor@apple.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">As an <b class="">amendment to SE-0140</b>, Swift will produce a warning when an optional value is converted to a value of type Any, e.g.,</div><div class=""><br class=""></div><div class=""><div class=""><font face="Menlo" class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>MyClass().doSomething(stringOpt) &nbsp;// warning: optional value of type&nbsp;‘String?’ is converted to an&nbsp;‘Any’</font></div></div><div class=""><font face="Menlo" class=""><span class="Apple-tab-span" style="white-space:pre">                                        </span>&nbsp; // note: use&nbsp;‘!’ to force-unwrap the optional</font></div><div class=""><font face="Menlo" class=""><span class="Apple-tab-span" style="white-space:pre">                                        </span>&nbsp; // note: use&nbsp;‘??’ to provide a default value if the optional is nil</font></div><div class=""><font face="Menlo" class=""><span class="Apple-tab-span" style="white-space:pre">                                        </span>&nbsp; // note: use&nbsp;‘as Any’ to silence this warning</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class="">Such a warning will address most accidental injections of optional values into Any, and the core team felt that this addresses accidental boxing of optional values better than leaving the opaque object types to fail fast in Objective-C code that inspects them (e.g., see&nbsp;<a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160905/026961.html" class="">this message</a>&nbsp;for a negative review partly on these grounds).</div></div></div></blockquote><br class=""></div><div>Is there a recommended pattern for defining a callee that actually wants to accept anything including optionals with no warning for the caller?&nbsp;</div><br class=""><div class=""><br class=""></div><div class="">--&nbsp;</div><div class="">Greg Parker &nbsp; &nbsp; <a href="mailto:gparker@apple.com" class="">gparker@apple.com</a>&nbsp; &nbsp; &nbsp;Runtime Wrangler</div><div class=""><br class=""></div><div class=""><br class=""></div></body></html>