]> granicus.if.org Git - clang/commitdiff
Fix <rdar://problem/6257675> error: member reference base type ('NSUserDefaults ...
authorSteve Naroff <snaroff@apple.com>
Wed, 22 Oct 2008 19:16:27 +0000 (19:16 +0000)
committerSteve Naroff <snaroff@apple.com>
Wed, 22 Oct 2008 19:16:27 +0000 (19:16 +0000)
Teach Sema::ActOnMemberReferenceExpr() to look through local category implementations associated with the class.

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

lib/Sema/SemaExpr.cpp
test/SemaObjC/property-11.m [new file with mode: 0644]

index 9292017d674c4495f1962737ad9c2706175418b6..5619eca4f00714deae40854727c3966eaf722c57 100644 (file)
@@ -977,6 +977,13 @@ ActOnMemberReferenceExpr(ExprTy *Base, SourceLocation OpLoc,
               ObjCImplementations[ClassDecl->getIdentifier()])
             Getter = ImpDecl->getInstanceMethod(Sel);
 
+    // Look through local category implementations associated with the class.
+    if (!Getter) {
+      for (unsigned i = 0; i < ObjCCategoryImpls.size() && !Getter; i++) {
+        if (ObjCCategoryImpls[i]->getClassInterface() == IFace)
+          Getter = ObjCCategoryImpls[i]->getInstanceMethod(Sel);
+      }
+    }
     if (Getter) {
       // If we found a getter then this may be a valid dot-reference, we
       // need to also look for the matching setter.
diff --git a/test/SemaObjC/property-11.m b/test/SemaObjC/property-11.m
new file mode 100644 (file)
index 0000000..8038328
--- /dev/null
@@ -0,0 +1,32 @@
+// RUN: clang -fsyntax-only -verify %s
+
+@interface NSSound
+@end
+@interface NSFont
+@end
+
+@interface NSSound (Adds)
+@end
+
+@implementation NSSound (Adds)
+- foo {
+  return self;
+}
+- (void)setFoo:obj {
+}
+@end
+
+@implementation NSFont (Adds)
+
+- xx {
+  NSSound *x;
+  id o;
+
+  o = [x foo]; 
+  o = x.foo;
+  [x setFoo:o];
+  x.foo = o;
+}
+
+@end
+