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