From 3306f961fa940754dfa0e4e34c57e0c57bea3890 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Thu, 12 Jan 2012 00:18:35 +0000 Subject: [PATCH] objective-c: fixes a regression in looking up names in class extensions and categories by recent refactoring of objc class ASTs. // rdar://1066654 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147982 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaDecl.cpp | 7 +++++-- test/SemaObjC/ContClassPropertyLookup.m | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index f30f1fa5be..dc8d6ec8cf 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -1255,8 +1255,11 @@ ObjCInterfaceDecl *Sema::getObjCInterfaceDecl(IdentifierInfo *&Id, Id = IDecl->getIdentifier(); } } - - return dyn_cast_or_null(IDecl); + ObjCInterfaceDecl *Def = dyn_cast_or_null(IDecl); + // This routine must always return a class definition, if any. + if (Def && Def->getDefinition()) + Def = Def->getDefinition(); + return Def; } /// getNonFieldDeclScope - Retrieves the innermost scope, starting diff --git a/test/SemaObjC/ContClassPropertyLookup.m b/test/SemaObjC/ContClassPropertyLookup.m index b3459c13e4..2bc376f696 100644 --- a/test/SemaObjC/ContClassPropertyLookup.m +++ b/test/SemaObjC/ContClassPropertyLookup.m @@ -16,3 +16,23 @@ @implementation MyObject @synthesize foo = _foo; @end + +// rdar://10666594 +@interface MPMediaItem +@end + +@class MPMediaItem; + +@interface MPMediaItem () +@property (nonatomic, readonly) id title; +@end + +@interface PodcastEpisodesViewController +@end + +@implementation PodcastEpisodesViewController +- (id) Meth { + MPMediaItem *episode; + return episode.title; +} +@end -- 2.40.0