[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
John McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Dec 15 18:50:50 PST 2017
rjmccall added a comment.
LGTM outside of a comment request; please feel free to commit when you'd made that change.
================
Comment at: lib/Sema/SemaExprObjC.cpp:1361
+ // pointer to the parent interface of the method when ARC is enabled (
+ // because self can't be reassigned when ARC is on).
+ if (Receiver && Receiver->isObjCSelfExpr()) {
----------------
You should update the comment to reflect that this isn't ARC-specific; I would suggest something like:
// In a class method, class messages to 'self' that return instancetype can be
// typed as the current class. We can safely do this in ARC because self can't
// be reassigned, and we do it unsafely outside of ARC because in practice people
// never reassign self in class methods and there's some virtue in not being
// aggressively pedantic.
https://reviews.llvm.org/D36790
More information about the cfe-commits
mailing list