<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=""><blockquote type="cite" class="">On Dec 12, 2016, at 2:46 PM, Joe Groff <<a href="mailto:jgroff@apple.com" class="">jgroff@apple.com</a>> wrote:<br class=""></blockquote><div><blockquote type="cite" class=""><br class="Apple-interchange-newline"><div class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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; float: none; display: inline !important;" class="">Everything *can* be bridged to an object as a result of SE-0116 ("id-as-Any"), so there's no longer such a thing as a "non-bridgable value type”.</span></div></blockquote><div><br class=""></div><div>Ah, so that arbitrary Swift types can be stashed in Objective-C userInfo dictionaries and the like. Of course. Still wish this could have just happened at the bridge, as part of whatever magic converts Arrays to NSArrays, Dictionaries to NSDictionaries, etc. Oh well.</div><br class=""><blockquote type="cite" class=""><div class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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; float: none; display: inline !important;" class="">#6 is a bug, since the AnyObject method lookup ought to produce `nil` if the ObjC method isn't implemented on the object.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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=""></div></blockquote><div><br class=""></div><div>Good to know that it’s a bug. Hopefully it’ll get fixed in a future release (or at least warn if the ? isn’t before the parens).</div><div><br class=""></div><div>By the way, while we’re at it, I managed to find a way to get the property version to crash by leaving out some question marks, as well:</div><div><div class=""><br class=""></div><div class=""><div style="margin: 0px; line-height: normal;" class="">print((s as AnyObject).foo as Any) // fatal error: unexpectedly found nil while unwrapping an Optional value</div></div><div style="margin: 0px; line-height: normal;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class="">Interestingly, it works in the context of string interpolation. 'print("\((s as AnyObject).foo)”)’ prints nil, just like you’d expect. It’s just when you pass it straight to print that the crash happens. Once again, the compiler doesn’t give us any kind of warning about this.</div></div><br class=""><blockquote type="cite" class=""><div class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">2. Why is there no obvious way to figure out whether something can actually be an object? The already kind of non-obvious “type(of: s) is AnyObject.Type” trick works to tell you if the thing is already a class, but not if something is bridgeable to a class; using it on a string, for example, returns false. And trying something like “type(of: s as AnyObject) is AnyObject.Type” returns true (?!), so that doesn’t work to detect bridgeable things.<br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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; float: none; display: inline !important;" class="">What are you trying to do that requires you to know whether something is a class or bridgable to a class (which, as mentioned above, includes everything)?</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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=""></div></blockquote><div><br class=""></div></div><div class="">The immediate use case? Avoiding the crash on #6. ;-) At least there turned out to be a workaround on that.</div><div class=""><br class=""></div><div class="">Beyond that? Making the whole thing less head-hurtingly complicated, and avoiding random crashing bugs popping up due to the difficulty of completely reasoning about how the whole thing works. But I was a fan of the lamentably departed SE-0083, so grumble, grumble.</div><div class=""><br class=""></div><div class="">Charles</div><div class=""><br class=""></div></body></html>