I've seen old (pre-Swift 3) posts online (e.g. http://stackoverflow.com/questions/28920232/why-do-integers-not-conform-to-the-anyobject-protocol) that address this, but my code worked yesterday before I used Xcode 8 GM to migrate it to Swift 3, and now it doesn't, so I'm trying to understand what's going on.
In this case, I have this code:
open class HttpServer
let clientSocketsLock = 0
open func start()
HttpServer.lock(self.clientSocketsLock) // ERROR HERE
open class func lock(_ handle: AnyObject, closure: () -> ())
I get the error "Argument type 'Int' does not conform to expected type 'AnyObject'" at the line marked above. What has changed here? Did Int's behavior change? Is that described somewhere? I tried googling "Swift 3 Int" and variations without much luck.
I did see one discussion that talked about how when passing an Int to AnyObject, it was implicitly converted to NSNumber, and that this behavior only applied to certain types (e.g. not Int32). How can I tell when this kind of behavior exists? Is there a way to look at the type's declaration to see (e.g. it conforms to a protocol, or has a compiler attribute, or something)?