1// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s 2 3// This test case tests the default behavior. 4 5// rdar://7933061 6 7@interface NSObject @end 8 9@interface NSArray : NSObject @end 10 11@interface MyClass : NSObject { 12} 13- (void)myMethod:(NSArray *)object; 14- (void)myMethod1:(NSObject *)object; // broken-note {{previous definition is here}} 15@end 16 17@implementation MyClass 18- (void)myMethod:(NSObject *)object { 19} 20- (void)myMethod1:(NSArray *)object { // broken-warning {{conflicting parameter types in implementation of 'myMethod1:': 'NSObject *' vs 'NSArray *'}} 21} 22@end 23 24 25@protocol MyProtocol @end 26 27@interface MyOtherClass : NSObject <MyProtocol> { 28} 29- (void)myMethod:(id <MyProtocol>)object; // broken-note {{previous definition is here}} 30- (void)myMethod1:(id <MyProtocol>)object; // broken-note {{previous definition is here}} 31@end 32 33@implementation MyOtherClass 34- (void)myMethod:(MyClass *)object { // broken-warning {{conflicting parameter types in implementation of 'myMethod:': 'id<MyProtocol>' vs 'MyClass *'}} 35} 36- (void)myMethod1:(MyClass<MyProtocol> *)object { // broken-warning {{conflicting parameter types in implementation of 'myMethod1:': 'id<MyProtocol>' vs 'MyClass<MyProtocol> *'}} 37} 38@end 39 40 41 42@interface A @end 43@interface B : A @end 44 45@interface Test1 {} 46- (void) test1:(A*) object; // broken-note {{previous definition is here}} 47- (void) test2:(B*) object; 48@end 49 50@implementation Test1 51- (void) test1:(B*) object {} // broken-warning {{conflicting parameter types in implementation of 'test1:': 'A *' vs 'B *'}} 52- (void) test2:(A*) object {} 53@end 54 55// rdar://problem/8597621 wants id -> A* to be an exception 56@interface Test2 {} 57- (void) test1:(id) object; // broken-note {{previous definition is here}} 58- (void) test2:(A*) object; 59@end 60@implementation Test2 61- (void) test1:(A*) object {} // broken-warning {{conflicting parameter types in implementation of 'test1:': 'id' vs 'A *'}} 62- (void) test2:(id) object {} 63@end 64 65@interface Test3 {} 66- (A*) test1; 67- (B*) test2; // broken-note {{previous definition is here}} 68@end 69 70@implementation Test3 71- (B*) test1 { return 0; } 72- (A*) test2 { return 0; } // broken-warning {{conflicting return type in implementation of 'test2': 'B *' vs 'A *'}} 73@end 74 75// The particular case of overriding with an id return is white-listed. 76@interface Test4 {} 77- (id) test1; 78- (A*) test2; 79@end 80@implementation Test4 81- (A*) test1 { return 0; } // id -> A* is rdar://problem/8596987 82- (id) test2 { return 0; } 83@end 84