How does clang objc select which selector to call for a given selector on ID?

given an id x and NSStatusItem and NSString in scope (which both do length), one returns int, the other CGFloat, how does clang decide which one to pick? It seems to pick NSString, but I can’t find the code that actually does this (or the rules that are used here)

It is undefined behaviour to do this. Clang will pick one, but it is not consistently guaranteed to pick the same one (particularly across compiler versions). With Apple's implementation of Objective-C, if it picks the wrong one then you will get a random value (and possibly stack corruption if the difference is between returning a scalar and a structure). With the GNUstep implementation, you will get an error at run time (and possibly an NSInvalidArgumentException, depending on what you're linking).