<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 <<a href="mailto:dgregor@apple.com" class="">dgregor@apple.com</a>> 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) // warning: optional value of type ‘String?’ is converted to an ‘Any’</font></div></div><div class=""><font face="Menlo" class=""><span class="Apple-tab-span" style="white-space:pre">                                        </span> // note: use ‘!’ to force-unwrap the optional</font></div><div class=""><font face="Menlo" class=""><span class="Apple-tab-span" style="white-space:pre">                                        </span> // note: use ‘??’ 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> // note: use ‘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 <a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160905/026961.html" class="">this message</a> 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? </div><br class=""><div class=""><br class=""></div><div class="">-- </div><div class="">Greg Parker <a href="mailto:gparker@apple.com" class="">gparker@apple.com</a> Runtime Wrangler</div><div class=""><br class=""></div><div class=""><br class=""></div></body></html>