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

jahanian fjahanian at apple.com
Fri May 30 11:57:19 PDT 2014


On May 30, 2014, at 11:41 AM, Argyrios Kyrtzidis <kyrtzidis at apple.com> wrote:

> 
>> On May 30, 2014, at 11:34 AM, Argyrios Kyrtzidis <kyrtzidis at apple.com> wrote:
>> 
>> 
>>> On May 30, 2014, at 11:13 AM, jahanian <fjahanian at apple.com> wrote:
>>> 
>>> Is this intentional, or a specific case for retain/release methods?
>> 
>> This also returns TRUE:
>> 
>> 	blk b = ^{};
>> 	BOOL res = [b respondsToSelector:@selector(isKindOfClass:)];
>> 
>> So blocks seem to respond to NSObject protocol selectors.
>> 
>>> In generally though it makes no sense
>>> to allow qualified id conversion of blocks pointers.
>> 
>> It would make sense for id<NSObject> if we would guarantee that blocks conform to NSObject protocol.
> 
> BTW, returns true as well:
> 
> 	blk b = ^{};
> 	BOOL res = [b conformsToProtocol:@protocol(NSObject)];

We should run this by the Foundation people. For example, this also returns 1:
BOOL res = [b respondsToSelector:@selector(dealloc)];
But dealloc is not a method of NSObject protocol. But it is a method
of NSObject class. It seems more and more that we should make an exception
for NSObject as block implements its protocol and class.

- Fariborz



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140530/f9335ba3/attachment.html>


More information about the cfe-commits mailing list