blob: 654cd0166fb50fd7f0e4ceacfbe0c3c1a89ccb5c [file] [log] [blame]
Patrick Beardacfbe9e2012-04-06 18:12:22 +00001// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
Andy Gibbsc6e68da2012-10-19 12:44:48 +00002// expected-no-diagnostics
John McCall071df462010-10-28 02:34:38 +00003
4// This test case tests the default behavior.
5
Fariborz Jahanianc080a332010-10-05 21:02:11 +00006// rdar://7933061
7
8@interface NSObject @end
9
10@interface NSArray : NSObject @end
11
12@interface MyClass : NSObject {
13}
John McCall071df462010-10-28 02:34:38 +000014- (void)myMethod:(NSArray *)object;
15- (void)myMethod1:(NSObject *)object; // broken-note {{previous definition is here}}
Fariborz Jahanianc080a332010-10-05 21:02:11 +000016@end
17
18@implementation MyClass
John McCall071df462010-10-28 02:34:38 +000019- (void)myMethod:(NSObject *)object {
Fariborz Jahanianc080a332010-10-05 21:02:11 +000020}
John McCall071df462010-10-28 02:34:38 +000021- (void)myMethod1:(NSArray *)object { // broken-warning {{conflicting parameter types in implementation of 'myMethod1:': 'NSObject *' vs 'NSArray *'}}
Fariborz Jahanianc080a332010-10-05 21:02:11 +000022}
23@end
24
25
26@protocol MyProtocol @end
27
28@interface MyOtherClass : NSObject <MyProtocol> {
29}
John McCall071df462010-10-28 02:34:38 +000030- (void)myMethod:(id <MyProtocol>)object; // broken-note {{previous definition is here}}
31- (void)myMethod1:(id <MyProtocol>)object; // broken-note {{previous definition is here}}
Fariborz Jahanianc080a332010-10-05 21:02:11 +000032@end
33
34@implementation MyOtherClass
John McCall071df462010-10-28 02:34:38 +000035- (void)myMethod:(MyClass *)object { // broken-warning {{conflicting parameter types in implementation of 'myMethod:': 'id<MyProtocol>' vs 'MyClass *'}}
Fariborz Jahanianc080a332010-10-05 21:02:11 +000036}
John McCall071df462010-10-28 02:34:38 +000037- (void)myMethod1:(MyClass<MyProtocol> *)object { // broken-warning {{conflicting parameter types in implementation of 'myMethod1:': 'id<MyProtocol>' vs 'MyClass<MyProtocol> *'}}
Fariborz Jahanianc080a332010-10-05 21:02:11 +000038}
39@end
John McCall071df462010-10-28 02:34:38 +000040
41
42
43@interface A @end
44@interface B : A @end
45
46@interface Test1 {}
47- (void) test1:(A*) object; // broken-note {{previous definition is here}}
48- (void) test2:(B*) object;
49@end
50
51@implementation Test1
52- (void) test1:(B*) object {} // broken-warning {{conflicting parameter types in implementation of 'test1:': 'A *' vs 'B *'}}
53- (void) test2:(A*) object {}
54@end
55
56// rdar://problem/8597621 wants id -> A* to be an exception
57@interface Test2 {}
58- (void) test1:(id) object; // broken-note {{previous definition is here}}
59- (void) test2:(A*) object;
60@end
61@implementation Test2
62- (void) test1:(A*) object {} // broken-warning {{conflicting parameter types in implementation of 'test1:': 'id' vs 'A *'}}
63- (void) test2:(id) object {}
64@end
65
66@interface Test3 {}
67- (A*) test1;
68- (B*) test2; // broken-note {{previous definition is here}}
69@end
70
71@implementation Test3
72- (B*) test1 { return 0; }
73- (A*) test2 { return 0; } // broken-warning {{conflicting return type in implementation of 'test2': 'B *' vs 'A *'}}
74@end
75
76// The particular case of overriding with an id return is white-listed.
77@interface Test4 {}
78- (id) test1;
79- (A*) test2;
80@end
81@implementation Test4
82- (A*) test1 { return 0; } // id -> A* is rdar://problem/8596987
83- (id) test2 { return 0; }
84@end