From 3985a324489dc4477b803bbb72f5d853a41324d3 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Mon, 17 Mar 2014 17:46:10 +0000 Subject: [PATCH] Objective-C. Do not warn when an instance method and class method with the same selctor but different argument types having one of them in class extension. // rdar://16312105 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@204065 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaDeclObjC.cpp | 4 +++- test/SemaObjC/class-extension-dup-methods.m | 13 +++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index 2bed6cac38..8f68852aaa 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -838,7 +838,9 @@ void Sema::DiagnoseClassExtensionDupMethods(ObjCCategoryDecl *CAT, return; for (const auto *Method : CAT->methods()) { const ObjCMethodDecl *&PrevMethod = MethodMap[Method->getSelector()]; - if (PrevMethod && !MatchTwoMethodDeclarations(Method, PrevMethod)) { + if (PrevMethod && + (PrevMethod->isInstanceMethod() == Method->isInstanceMethod()) && + !MatchTwoMethodDeclarations(Method, PrevMethod)) { Diag(Method->getLocation(), diag::err_duplicate_method_decl) << Method->getDeclName(); Diag(PrevMethod->getLocation(), diag::note_previous_declaration); diff --git a/test/SemaObjC/class-extension-dup-methods.m b/test/SemaObjC/class-extension-dup-methods.m index 692ff8c68a..5f463aed16 100644 --- a/test/SemaObjC/class-extension-dup-methods.m +++ b/test/SemaObjC/class-extension-dup-methods.m @@ -13,3 +13,16 @@ + (int) InstMeth; - (int) OK; @end + +// rdar://16312105 +@class NSObject; + +__attribute__((objc_root_class)) @interface AppDelegate ++ (void)someMethodWithArgument:(NSObject *)argument; ++ (void)someMethodWithArgument:(NSObject *)argument : (NSObject*) argument2; // expected-note {{previous declaration is here}} +@end + +@interface AppDelegate () +- (void)someMethodWithArgument:(float)argument; // OK. No warning to be issued here. ++ (void)someMethodWithArgument:(float)argument : (float)argument2; // expected-error {{duplicate declaration of method 'someMethodWithArgument::'}} +@end -- 2.40.0