summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Naroff <snaroff@apple.com>2008-12-08 20:57:28 +0000
committerSteve Naroff <snaroff@apple.com>2008-12-08 20:57:28 +0000
commit5fd31b17df35c03b963861c934d3c3690732b42e (patch)
tree6c71ca99c58ca1231f6a72f8be01200cb2a53b21
parentf1ab600362a06e6e3655259992cd6c89a168b75d (diff)
downloadbcm5719-llvm-5fd31b17df35c03b963861c934d3c3690732b42e.tar.gz
bcm5719-llvm-5fd31b17df35c03b963861c934d3c3690732b42e.zip
ObjCInterfaceDecl::lookupInstanceMethod() needs to look through a categories protocols.
Fixes <rdar://problem/6418640> clang on prokit: error: incompatible type returning 'id', expected 'NSSize' llvm-svn: 60716
-rw-r--r--clang/lib/AST/DeclObjC.cpp8
-rw-r--r--clang/test/SemaObjC/super-cat-prot.m48
2 files changed, 56 insertions, 0 deletions
diff --git a/clang/lib/AST/DeclObjC.cpp b/clang/lib/AST/DeclObjC.cpp
index 0458282fb38..85b8ec14e04 100644
--- a/clang/lib/AST/DeclObjC.cpp
+++ b/clang/lib/AST/DeclObjC.cpp
@@ -685,6 +685,14 @@ ObjCMethodDecl *ObjCInterfaceDecl::lookupInstanceMethod(Selector Sel) {
while (CatDecl) {
if ((MethodDecl = CatDecl->getInstanceMethod(Sel)))
return MethodDecl;
+
+ // Didn't find one yet - look through protocols.
+ const ObjCList<ObjCProtocolDecl> &Protocols =
+ CatDecl->getReferencedProtocols();
+ for (ObjCList<ObjCProtocolDecl>::iterator I = Protocols.begin(),
+ E = Protocols.end(); I != E; ++I)
+ if ((MethodDecl = (*I)->getInstanceMethod(Sel)))
+ return MethodDecl;
CatDecl = CatDecl->getNextClassCategory();
}
ClassDecl = ClassDecl->getSuperClass();
diff --git a/clang/test/SemaObjC/super-cat-prot.m b/clang/test/SemaObjC/super-cat-prot.m
new file mode 100644
index 00000000000..ef4c0ebc3f0
--- /dev/null
+++ b/clang/test/SemaObjC/super-cat-prot.m
@@ -0,0 +1,48 @@
+// RUN: clang -fsyntax-only -verify %s
+typedef signed char BOOL;
+typedef unsigned int NSUInteger;
+@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+@protocol NSObject - (BOOL)isEqual:(id)object; @end
+@protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder; @end
+@interface NSObject <NSObject> {} @end
+typedef float CGFloat;
+typedef struct _NSSize {} NSSize;
+typedef struct _NSRect {} NSRect;
+@interface NSResponder : NSObject <NSCoding> {} @end
+@protocol NSAnimatablePropertyContainer - (id)animator; @end
+extern NSString *NSAnimationTriggerOrderIn ;
+@interface NSView : NSResponder <NSAnimatablePropertyContainer> {} @end
+@class NSAttributedString, NSEvent, NSFont, NSFormatter, NSImage, NSMenu, NSText, NSView;
+enum { NSBoxPrimary = 0, NSBoxSecondary = 1, NSBoxSeparator = 2, NSBoxOldStyle = 3, NSBoxCustom = 4};
+typedef NSUInteger NSBoxType;
+@interface NSBox : NSView {} - (NSBoxType)boxType; @end
+@class NSArray, NSError, NSImage, NSView, NSNotificationCenter, NSURL;
+@interface NSProBox:NSBox {} @end
+enum IBKnobPosition { IBNoKnobPosition = -1, IBBottomLeftKnobPosition = 0,
+ IBMiddleLeftKnobPosition, IBTopLeftKnobPosition,
+ IBTopMiddleKnobPosition, IBTopRightKnobPosition,
+ IBMiddleRightKnobPosition, IBBottomRightKnobPosition,
+ IBBottomMiddleKnobPosition };
+typedef enum IBKnobPosition IBKnobPosition;
+typedef struct _IBInset {} IBInset;
+@protocol IBObjectProtocol -(NSString *)inspectorClassName; @end
+@protocol IBViewProtocol
+ -(NSSize)minimumFrameSizeFromKnobPosition:(IBKnobPosition)position;
+ -(IBInset)ibShadowInset;
+@end
+@class NSPasteboard;
+@interface NSObject (NSObject_IBObjectProtocol) <IBObjectProtocol> @end
+@interface NSView (NSView_IBViewProtocol) <IBViewProtocol> - (NSRect)layoutRect; @end
+typedef enum { NSProTextFieldSquareBezel = 0, NSProTextFieldRoundedBezel = 1, NSProTextFieldDisplayBezel = 2 } MKModuleReusePolicy;
+@implementation NSProBox(IBAdditions)
+-(NSString *)inspectorClassName {}
+-(IBInset)ibShadowInset {
+ if ([self boxType] == NSBoxSeparator) {
+ return [super ibShadowInset];
+ }
+}
+-(NSSize)minimumFrameSizeFromKnobPosition:(IBKnobPosition)knobPosition {
+ if ([self boxType] != NSBoxSeparator)
+ return [super minimumFrameSizeFromKnobPosition:knobPosition];
+}
+@end
OpenPOWER on IntegriCloud