AttributeList *AttrList, tok::ObjCKeywordKind MethodImplKind,
bool isVariadic = false);
+ // Helper method for ActOnClassMethod/ActOnInstanceMethod.
+ // Will search "local" class/category implementations for a method decl.
+ // Returns 0 if no method is found.
+ ObjCMethodDecl *LookupPrivateMethod(Selector Sel, ObjCInterfaceDecl *CDecl);
+
// ActOnClassMessage - used for both unary and keyword messages.
// ArgExprs is optional - if it is present, the number of expressions
// is obtained from NumArgs.
return anyIncompatibleArgs;
}
+// Helper method for ActOnClassMethod/ActOnInstanceMethod.
+// Will search "local" class/category implementations for a method decl.
+// Returns 0 if no method is found.
+ObjCMethodDecl *Sema::LookupPrivateMethod(Selector Sel,
+ ObjCInterfaceDecl *ClassDecl) {
+ ObjCMethodDecl *Method = 0;
+
+ if (ObjCImplementationDecl *ImpDecl =
+ ObjCImplementations[ClassDecl->getIdentifier()])
+ Method = ImpDecl->getClassMethod(Sel);
+
+ // Look through local category implementations associated with the class.
+ if (!Method) {
+ for (unsigned i = 0; i < ObjCCategoryImpls.size() && !Method; i++) {
+ if (ObjCCategoryImpls[i]->getClassInterface() == ClassDecl)
+ Method = ObjCCategoryImpls[i]->getClassMethod(Sel);
+ }
+ }
+ return Method;
+}
+
// ActOnClassMessage - used for both unary and keyword messages.
// ArgExprs is optional - if it is present, the number of expressions
// is obtained from Sel.getNumArgs().
Method = ClassDecl->lookupClassMethod(Sel);
// If we have an implementation in scope, check "private" methods.
- if (!Method) {
- if (ObjCImplementationDecl *ImpDecl =
- ObjCImplementations[ClassDecl->getIdentifier()])
- Method = ImpDecl->getClassMethod(Sel);
-
- // Look through local category implementations associated with the class.
- if (!Method) {
- for (unsigned i = 0; i < ObjCCategoryImpls.size() && !Method; i++) {
- if (ObjCCategoryImpls[i]->getClassInterface() == ClassDecl)
- Method = ObjCCategoryImpls[i]->getClassMethod(Sel);
- }
- }
- }
+ if (!Method)
+ Method = LookupPrivateMethod(Sel, ClassDecl);
+
// Before we give up, check if the selector is an instance method.
if (!Method)
Method = ClassDecl->lookupInstanceMethod(Sel);
// First check the public methods in the class interface.
Method = ClassDecl->lookupClassMethod(Sel);
- if (!Method) {
- // If we have an implementation in scope, check "private" methods.
- if (ObjCImplementationDecl *ImpDecl =
- ObjCImplementations[ClassDecl->getIdentifier()])
- Method = ImpDecl->getClassMethod(Sel);
- }
+ if (!Method)
+ Method = LookupPrivateMethod(Sel, ClassDecl);
}
if (Method && DiagnoseUseOfDecl(Method, receiverLoc))
return true;
--- /dev/null
+// RUN: clang -fsyntax-only -verify %s
+
+typedef struct objc_class *Class;
+@interface NSObject
+- (Class)class;
+@end
+@interface Bar : NSObject
+@end
+@interface Bar (Cat)
+@end
+
+// NOTE: No class implementation for Bar precedes this category definition.
+@implementation Bar (Cat)
+
+// private method.
++ classMethod { return self; }
+
+- instanceMethod {
+ [[self class] classMethod];
+}
+
+@end
\ No newline at end of file