]> granicus.if.org Git - clang/commitdiff
Method implemented in class's implementation may implement
authorFariborz Jahanian <fjahanian@apple.com>
Fri, 8 Oct 2010 22:59:25 +0000 (22:59 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Fri, 8 Oct 2010 22:59:25 +0000 (22:59 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116118 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDeclObjC.cpp
test/SemaObjC/metod-in-class-extension-impl.m [new file with mode: 0644]

index 09502a49233e368fb19c6c530d77fd60273d6dcb..74bd00340c69653bc0b62f839718bb765f3a8645 100644 (file)
@@ -924,7 +924,16 @@ void Sema::MatchAllMethodDeclarations(const llvm::DenseSet<Selector> &InsMap,
       WarnConflictingTypedMethods(ImpMethodDecl, IntfMethodDecl);
     }
   }
+  
   if (ObjCInterfaceDecl *I = dyn_cast<ObjCInterfaceDecl> (CDecl)) {
+    // Also methods in class extensions need be looked at next.
+    for (const ObjCCategoryDecl *ClsExtDecl = I->getFirstClassExtension(); 
+         ClsExtDecl; ClsExtDecl = ClsExtDecl->getNextClassExtension())
+      MatchAllMethodDeclarations(InsMap, ClsMap, InsMapSeen, ClsMapSeen,
+                                 IMPDecl,
+                                 const_cast<ObjCCategoryDecl *>(ClsExtDecl), 
+                                 IncompleteImpl, false);
+    
     // Check for any implementation of a methods declared in protocol.
     for (ObjCInterfaceDecl::all_protocol_iterator
           PI = I->all_referenced_protocol_begin(),
diff --git a/test/SemaObjC/metod-in-class-extension-impl.m b/test/SemaObjC/metod-in-class-extension-impl.m
new file mode 100644 (file)
index 0000000..c205322
--- /dev/null
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1  -fsyntax-only -verify %s
+// rdar://8530080
+
+@protocol ViewDelegate @end
+
+@interface NSTextView
+- (id <ViewDelegate>)delegate;
+@end
+
+@interface FooTextView : NSTextView
+@end
+
+@interface FooTextView() 
+- (id)delegate;
+@end
+
+@implementation FooTextView
+- (id)delegate {return 0; }
+@end
+