Prior to this patch, messages to self in class methods were treated as instance methods to a Class value. When these methods returned instancetype the compiler only saw id through the instancetype, and not the Interface *. This caused problems when that return value was a receiver in a message send, as the compiler couldn't select the right method declaration and had to rely on a selection from the global method pool.
This patch modifies the semantics of such message sends and uses class messages that are dispatched to the interface that corresponds to the class that contains the class method. This ensures that instancetypes are correctly interpreted by the compiler. This is an ARC only change, since non-ARC code can reassign self. The type dectltype(self) is used to store the self receiver in the class message to ensure that self remains in the AST.
Thanks for taking a look.
rdar://20940997
You should update the comment to reflect that this isn't ARC-specific; I would suggest something like: