[PATCH] D67983: [ObjC] Diagnose implicit type coercion from ObjC 'Class' to object pointer types.

James Y Knight via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 28 12:46:34 PDT 2019


jyknight added a comment.

In D67983#1723681 <https://reviews.llvm.org/D67983#1723681>, @rjmccall wrote:

> We could probably do a quick check to see if the class informally conforms to the protocol.  `+copyWithZone` seems to be marked unavailable in ARC; not sure if that would cause problems for such a check.


What kind of check did you have in mind? We might hard-code the compiler to think that the "Class" type "implements" NSObject/NSCopying and thus is implicitly convertible to `id<NSObject>` and `id<NSCopying>`. That usually would be OK since the default metaclass in the normal runtime in fact does so. However, there's no such guarantee, and that kind of hardcoding seems generally kinda sketchy.

Given that this code was already being diagnosed for a long time in ObjC mode, I'm not sure that adding such a hack is really warranted. I'll add a bit to the release notes, though.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67983/new/

https://reviews.llvm.org/D67983





More information about the cfe-commits mailing list