Index: lib/Sema/SemaCodeComplete.cpp =================================================================== --- lib/Sema/SemaCodeComplete.cpp +++ lib/Sema/SemaCodeComplete.cpp @@ -3720,20 +3720,21 @@ Results.AddResult(Result("template")); } } - } else if (!IsArrow && BaseType->getAsObjCInterfacePointerType()) { + } else if (!IsArrow && BaseType->isObjCObjectPointerType()) { // Objective-C property reference. AddedPropertiesSet AddedProperties; - - // Add property results based on our interface. - const ObjCObjectPointerType *ObjCPtr - = BaseType->getAsObjCInterfacePointerType(); - assert(ObjCPtr && "Non-NULL pointer guaranteed above!"); - AddObjCProperties(CCContext, ObjCPtr->getInterfaceDecl(), true, - /*AllowNullaryMethods=*/true, CurContext, - AddedProperties, Results); - + + if (const ObjCObjectPointerType *ObjCPtr = + BaseType->getAsObjCInterfacePointerType()) { + // Add property results based on our interface. + assert(ObjCPtr && "Non-NULL pointer guaranteed above!"); + AddObjCProperties(CCContext, ObjCPtr->getInterfaceDecl(), true, + /*AllowNullaryMethods=*/true, CurContext, + AddedProperties, Results); + } + // Add properties from the protocols in a qualified interface. - for (auto *I : ObjCPtr->quals()) + for (auto *I : BaseType->getAs()->quals()) AddObjCProperties(CCContext, I, true, /*AllowNullaryMethods=*/true, CurContext, AddedProperties, Results); } else if ((IsArrow && BaseType->isObjCObjectPointerType()) || Index: test/CodeCompletion/objc-protocol-member-access.m =================================================================== --- /dev/null +++ test/CodeCompletion/objc-protocol-member-access.m @@ -0,0 +1,24 @@ +// Note: the run lines follow their respective tests, since line/column +// matter in this test. + +@protocol Bar +@property (readonly) int bar; +@end + +@protocol Foo + +@property (nonatomic, readonly) int foo; +- (void)foobar: (int)x; + +@end + +int getFoo(id object) { + id modelObject = (id)object; + int foo = modelObject.; + return foo; +} + +// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:17:25 %s -o - | FileCheck %s +// CHECK: bar : [#int#]bar +// CHECK: foo : [#int#]foo +// CHECK-NOT: foobar