Curious ObjC typechecking... bug?

Why does the following pass Clang's type checker?

@protocol PF

@interface Foo : NSObject <PF>
- (double) pf;

@implementation Foo
- (double) pf { return 2.0; }

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?


Try -Woverriding-method-mismatch option.

- Fariborz

Try *-Woverriding-method-mismatch option.*

Ah, thanks.

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



It is plausible that people may want to override protocol’s methods in adapting classes with
different types. But I am not sure if this is the reason or it is legacy of gcc not insisting on matching types.

- Fariborz