[cfe-dev] Curious ObjC typechecking... bug?

Jonathan Roelofs jonathan at codesourcery.com
Fri Apr 10 09:03:54 PDT 2015



On 4/10/15 9:54 AM, jahanian wrote:
> Try *-Woverriding-method-mismatch option.*
> *

Ah, thanks.

Is there a useful pattern that's the reason why that one isn't on by 
default?


Cheers,

Jon

> *
> *- Fariborz*
> *
> *
>> On Apr 9, 2015, at 5:35 PM, Jonathan Roelofs
>> <jonathan at codesourcery.com <mailto:jonathan at codesourcery.com>> wrote:
>>
>> Why does the following pass Clang's type checker?
>>
>> @protocol PF
>> -(int)pf;
>> @end
>>
>> @interface Foo : NSObject <PF>
>> - (double) pf;
>> @end
>>
>> @implementation Foo
>> - (double) pf { return 2.0; }
>> @end
>>
>> It seems to me that there should at least be a "return type differs"
>> warning because 'pf' in the protocol has a different signature than
>> 'pf' in the interface... if not an error, because 'Foo' doesn't really
>> implement 'PF'.
>>
>> I could also be missing some language rule here. Thoughts?
>>
>>
>> Jon
>>
>> --
>> Jon Roelofs
>> jonathan at codesourcery.com <mailto:jonathan at codesourcery.com>
>> CodeSourcery / Mentor Embedded
>

-- 
Jon Roelofs
jonathan at codesourcery.com
CodeSourcery / Mentor Embedded



More information about the cfe-dev mailing list