when in the context of an @implementation, look for private methods in the
@implementation to resolve nullary selector references.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53845 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 9cb8b98..4f085d2 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -635,14 +635,26 @@
(IFTy = PTy->getPointeeType()->getAsObjCInterfaceType())) {
ObjCInterfaceDecl *IFace = IFTy->getDecl();
+ // FIXME: The logic for looking up nullary and unary selectors should be
+ // shared with the code in ActOnInstanceMessage.
+
// Before we look for explicit property declarations, we check for
// nullary methods (which allow '.' notation).
Selector Sel = PP.getSelectorTable().getNullarySelector(&Member);
-
if (ObjCMethodDecl *MD = IFace->lookupInstanceMethod(Sel))
return new ObjCPropertyRefExpr(MD, MD->getResultType(),
MemberLoc, BaseExpr);
+ // If this reference is in an @implementation, check for 'private' methods.
+ if (ObjCMethodDecl *CurMeth = getCurMethodDecl()) {
+ if (ObjCInterfaceDecl *ClassDecl = CurMeth->getClassInterface())
+ if (ObjCImplementationDecl *ImpDecl =
+ ObjCImplementations[ClassDecl->getIdentifier()])
+ if (ObjCMethodDecl *MD = ImpDecl->getInstanceMethod(Sel))
+ return new ObjCPropertyRefExpr(MD, MD->getResultType(),
+ MemberLoc, BaseExpr);
+ }
+
// FIXME: Need to deal with setter methods that take 1 argument. E.g.:
// @interface NSBundle : NSObject {}
// - (NSString *)bundlePath;