void Sema::DiagnoseUnimplementedProperties(Scope *S, ObjCImplDecl* IMPDecl,
ObjCContainerDecl *CDecl,
const SelectorSet &InsMap) {
- ObjCContainerDecl::PropertyMap SuperPropMap;
- if (ObjCInterfaceDecl *IDecl = dyn_cast<ObjCInterfaceDecl>(CDecl))
- CollectSuperClassPropertyImplementations(IDecl, SuperPropMap);
+ ObjCContainerDecl::PropertyMap NoNeedToImplPropMap;
+ ObjCInterfaceDecl *IDecl;
+ // Gather properties which need not be implemented in this class
+ // or category.
+ if (!(IDecl = dyn_cast<ObjCInterfaceDecl>(CDecl)))
+ if (ObjCCategoryDecl *C = dyn_cast<ObjCCategoryDecl>(CDecl)) {
+ // For categories, no need to implement properties declared in
+ // its primary class (and its super classes) if property is
+ // declared in one of those containers.
+ if ((IDecl = C->getClassInterface()))
+ IDecl->collectPropertiesToImplement(NoNeedToImplPropMap);
+ }
+ if (IDecl)
+ CollectSuperClassPropertyImplementations(IDecl, NoNeedToImplPropMap);
ObjCContainerDecl::PropertyMap PropMap;
- CollectImmediateProperties(CDecl, PropMap, SuperPropMap);
+ CollectImmediateProperties(CDecl, PropMap, NoNeedToImplPropMap);
if (PropMap.empty())
return;
@implementation MyClass (public)// expected-warning {{property 'foo' requires method 'setFoo:' to be defined }}
@end
+
+// rdar://12568064
+// No warn of unimplemented property of protocols in category,
+// when those properties will be implemented in category's primary
+// class or one of its super classes.
+@interface HBSuperclass
+@property (nonatomic) char myProperty;
+@property (nonatomic) char myProperty2;
+@end
+
+@interface HBClass : HBSuperclass
+@end
+
+@protocol HBProtocol
+@property (nonatomic) char myProperty;
+@property (nonatomic) char myProperty2;
+@end
+
+@interface HBSuperclass (HBSCategory)<HBProtocol>
+@end
+
+@implementation HBSuperclass (HBSCategory)
+@end
+
+@interface HBClass (HBCategory)<HBProtocol>
+@end
+
+@implementation HBClass (HBCategory)
+@end