Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Obj-C: Protocol implemented in category leads to warnings #7340

Closed Quuxplusone closed 14 years ago

Quuxplusone commented 14 years ago
Bugzilla Link PR6890
Status RESOLVED FIXED
Importance P normal
Reported by Dave Keck (davekeck@gmail.com)
Reported on 2010-04-21 22:17:17 -0700
Last modified on 2010-04-22 10:41:21 -0700
Version unspecified
Hardware Macintosh MacOS X
CC clattner@nondot.org, fjahanian@apple.com
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
The following code gives warnings when it shouldn't:

=======================================

#import <Foundation/Foundation.h>

@protocol MyObject_Protocol
- (void)doSomethingFancy;
@end

@interface MyObject : NSObject <MyObject_Protocol>
{
}
@end

@implementation MyObject
@end

@implementation MyObject (More)
- (void)doSomethingFancy
{
    NSLog(@"meow mix");
}
@end

=======================================

As you can see, MyObject does indeed implement the MyObject_Protocol protocol,
it's just implemented in a category of MyObject. The warnings given are:

    warning: incomplete implementation
    warning: method definition for 'doSomethingFancy' not found
Quuxplusone commented 14 years ago
Purpose of categories are to implement new methods for their class.
Implementation of doSomethingFancy
in the category implements a new method and has no relationship to
doSomethingFancy
declared in the protocol. Conforming
class still must implement protocol's method in its own @implementation.