[PATCH] D36790: [ObjC] Messages to 'self' in class methods that return 'instancetype' should use the pointer to the class as the result type of the message

Alex Lorenz via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 15 14:16:08 PST 2017

arphaman added inline comments.

Comment at: lib/Sema/SemaExprObjC.cpp:1357
+        (ReceiverType->isObjCClassOrClassKindOfType() ||
+         ReceiverType->isObjCQualifiedClassType()) &&
+        Receiver->isObjCSelfExpr() && getLangOpts().ObjCAutoRefCount) {
rjmccall wrote:
> What's the purpose of these two checks?  I believe one of these is required in order to have decided that we're making a class message anyway, and regardless I don't understand why they would affect your logic.
> I don't think you should vary the logic here based on whether you're in ARC.  Just assume that the user isn't doing silly stuff like reassigning self to random values.  No, it's not strictly sound, but it's sound enough.
You're right, "isClassMessage" already checks these. The original intent was to ensure that self is an `instancetype`. I removed them.


More information about the cfe-commits mailing list