diff options
| -rw-r--r-- | clang/lib/Sema/SemaDeclObjC.cpp | 10 | ||||
| -rw-r--r-- | clang/test/SemaObjC/method-conflict-2.m | 49 |
2 files changed, 59 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp index 93620a1d82c..aa6eff700d7 100644 --- a/clang/lib/Sema/SemaDeclObjC.cpp +++ b/clang/lib/Sema/SemaDeclObjC.cpp @@ -1773,6 +1773,16 @@ void Sema::MatchAllMethodDeclarations(const SelectorSet &InsMap, } } + if (ObjCProtocolDecl *PD = dyn_cast<ObjCProtocolDecl> (CDecl)) { + // Also, check for methods declared in protocols inherited by + // this protocol. + for (ObjCProtocolDecl::protocol_iterator + PI = PD->protocol_begin(), E = PD->protocol_end(); PI != E; ++PI) + MatchAllMethodDeclarations(InsMap, ClsMap, InsMapSeen, ClsMapSeen, + IMPDecl, (*PI), IncompleteImpl, false, + WarnCategoryMethodImpl); + } + if (ObjCInterfaceDecl *I = dyn_cast<ObjCInterfaceDecl> (CDecl)) { // when checking that methods in implementation match their declaration, // i.e. when WarnCategoryMethodImpl is false, check declarations in class diff --git a/clang/test/SemaObjC/method-conflict-2.m b/clang/test/SemaObjC/method-conflict-2.m index ec80a433cc7..47c3d6c2c23 100644 --- a/clang/test/SemaObjC/method-conflict-2.m +++ b/clang/test/SemaObjC/method-conflict-2.m @@ -64,3 +64,52 @@ typedef long long int64_t; return 0; } @end + +// rdar://14650159 +// Tests that property inherited indirectly from a nested protocol +// is seen by the method implementation type matching logic before +// method in super class is seen. This fixes the warning coming +// out of that method mismatch. +@interface NSObject (NSDict) +- (void)setValue:(id)value; +- (id)value; +@end + +@protocol ProtocolWithValue +@property (nonatomic) unsigned value; +@end + +@protocol InterveningProtocol <ProtocolWithValue> +@end + +@interface UsesProtocolWithValue : NSObject <ProtocolWithValue> +@end + +@implementation UsesProtocolWithValue +@synthesize value=_value; +- (unsigned) value +{ + return _value; +} +- (void) setValue:(unsigned)value +{ + _value = value; +} +@end + + +@interface UsesInterveningProtocol : NSObject <InterveningProtocol> +@end + +@implementation UsesInterveningProtocol + +@synthesize value=_value; +- (unsigned) value +{ + return _value; +} +- (void) setValue:(unsigned)value +{ + _value = value; +} +@end |

