Skip to content

Commit 73853e5

Browse files
author
Fariborz Jahanian
committed
Method implemented in class's implementation may implement
one declared in class's extension and not one declared in class's superclass. This supresses a bogus warning on method type mismatch. Fixes //rdar: // 8530080 llvm-svn: 116118
1 parent bfde8dc commit 73853e5

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

clang/lib/Sema/SemaDeclObjC.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,16 @@ void Sema::MatchAllMethodDeclarations(const llvm::DenseSet<Selector> &InsMap,
924924
WarnConflictingTypedMethods(ImpMethodDecl, IntfMethodDecl);
925925
}
926926
}
927+
927928
if (ObjCInterfaceDecl *I = dyn_cast<ObjCInterfaceDecl> (CDecl)) {
929+
// Also methods in class extensions need be looked at next.
930+
for (const ObjCCategoryDecl *ClsExtDecl = I->getFirstClassExtension();
931+
ClsExtDecl; ClsExtDecl = ClsExtDecl->getNextClassExtension())
932+
MatchAllMethodDeclarations(InsMap, ClsMap, InsMapSeen, ClsMapSeen,
933+
IMPDecl,
934+
const_cast<ObjCCategoryDecl *>(ClsExtDecl),
935+
IncompleteImpl, false);
936+
928937
// Check for any implementation of a methods declared in protocol.
929938
for (ObjCInterfaceDecl::all_protocol_iterator
930939
PI = I->all_referenced_protocol_begin(),
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// RUN: %clang_cc1 -fsyntax-only -verify %s
2+
// rdar://8530080
3+
4+
@protocol ViewDelegate @end
5+
6+
@interface NSTextView
7+
- (id <ViewDelegate>)delegate;
8+
@end
9+
10+
@interface FooTextView : NSTextView
11+
@end
12+
13+
@interface FooTextView()
14+
- (id)delegate;
15+
@end
16+
17+
@implementation FooTextView
18+
- (id)delegate {return 0; }
19+
@end
20+

0 commit comments

Comments
 (0)