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

Alex Lorenz via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 10 12:09:31 PST 2020


arphaman added a comment.

In D67983#1863981 <https://reviews.llvm.org/D67983#1863981>, @jyknight wrote:

> In D67983#1863019 <https://reviews.llvm.org/D67983#1863019>, @arphaman wrote:
>
> > @jyknight @rjmccall I'm not sure this change is 100% fine. For example, the following code no longer compiles with ARC:
> >
> >   @protocol Delegate
> >   @end
> >  
> >   @interface X <Delegate>
> >  
> >   @end
> >  
> >   @interface Y
> >   @property id<Delegate> d;
> >   @end
> >  
> >   @implementation X
> >  
> >   + (void)foo:(Y *)y with:(X*)x {
> >    y.d = self; // error: assigning to 'id<Delegate>' from incompatible type 'const Class'
> >    y.d = x;     // fine
> >   }
> >  
> >   @end
> >
>
>
> Your error looks correct to me -- "self" in a classmethod is not an instance, but the class itself. And while instances of X implement "Delegate", the Class does not.


Got it, thanks! We might need to add a flag to allow the old behavior temporarily to accommodate our codebase while it's being updated.


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