From dc4df51d32dea56fbec79037570832dffbcc14e6 Mon Sep 17 00:00:00 2001 From: John McCall Date: Mon, 7 Nov 2011 22:49:50 +0000 Subject: [PATCH] There are some crazy cases that LookupMethodInReceiverType doesn't duplicate, but they all surface as implicit properties. It's also a useful optimization to not duplicate the implicit getter lookup. So, trust the getter lookup that was already done in these cases. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144031 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaPseudoObject.cpp | 9 ++++++++- test/SemaObjC/property.m | 9 +++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/Sema/SemaPseudoObject.cpp b/lib/Sema/SemaPseudoObject.cpp index b3ed145b15..cf43fcad05 100644 --- a/lib/Sema/SemaPseudoObject.cpp +++ b/lib/Sema/SemaPseudoObject.cpp @@ -418,7 +418,14 @@ static ObjCMethodDecl *LookupMethodInReceiverType(Sema &S, Selector sel, bool ObjCPropertyOpBuilder::findGetter() { if (Getter) return true; - Getter = LookupMethodInReceiverType(S, RefExpr->getGetterSelector(), RefExpr); + // For implicit properties, just trust the lookup we already did. + if (RefExpr->isImplicitProperty()) { + Getter = RefExpr->getImplicitPropertyGetter(); + return (Getter != 0); + } + + ObjCPropertyDecl *prop = RefExpr->getExplicitProperty(); + Getter = LookupMethodInReceiverType(S, prop->getGetterName(), RefExpr); return (Getter != 0); } diff --git a/test/SemaObjC/property.m b/test/SemaObjC/property.m index 7d1cb7a361..a43811d824 100644 --- a/test/SemaObjC/property.m +++ b/test/SemaObjC/property.m @@ -65,3 +65,12 @@ typedef id BYObjectIdentifier; // rdar://10127639 @synthesize window; // expected-error {{missing context for property implementation declaration}} + +// rdar://10408414 +Class test6_getClass(); +@interface Test6 +@end +@implementation Test6 ++ (float) globalValue { return 5.0f; } ++ (float) gv { return test6_getClass().globalValue; } +@end -- 2.40.0