r209906 - Objective-C. Diagnose assigning a block pointer type to

Jordan Rose jordan_rose at apple.com
Fri May 30 11:03:10 PDT 2014


I think I agree with Fariborz on this one. I don't remember us ever promising that blocks implement the NSObject protocol, just that they are valid Objective-C objects and that they implement -retain, -release, and -copy. The spec on the Clang site doesn't even promise -retain. (http://clang.llvm.org/docs/BlockLanguageSpec.html#objective-c-extensions)

The developer can always cast if they really need this.

Jordan


On May 30, 2014, at 10:49 , jahanian <fjahanian at apple.com> wrote:

> It makes no sense to assign block to an object conforming to protocols.
> Such objects must implement methods of those protocols which  blocks cannot.
> I explicitly ruled this out. Did you see this in an actual user code? Curious to see how it is being used.
> 
> - Fariborz
> 
> On May 30, 2014, at 10:32 AM, Argyrios Kyrtzidis <kyrtzidis at apple.com> wrote:
> 
>> This is giving an error in the following case, is this correct ?
>> 
>> #import <Foundation/Foundation.h>
>> 
>> typedef void(^blk)(void);
>> 
>> void foo(blk b) {
>> 	id<NSObject> x = b; // error: initializing 'id<NSObject>' with an expression of incompatible type 'blk' (aka 'void (^)(void)')
>> }
>> 
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list